From 26e5915000652f4807e337a2b370ce0051972f04 Mon Sep 17 00:00:00 2001 From: Arturo Espinosa Date: Mon, 20 Apr 1998 18:00:54 +0000 Subject: A lot of usability changes to GnomeCal -miguel svn path=/trunk/; revision=168 --- calendar/gui/view-utils.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'calendar/gui/view-utils.c') diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c index ccbe125291..0c074bd944 100644 --- a/calendar/gui/view-utils.c +++ b/calendar/gui/view-utils.c @@ -2,19 +2,41 @@ * * Copyright (C) 1998 The Free Software Foundation * - * Author: Federico Mena + * Authors: Federico Mena + * Miguel de Icaza */ #include #include "view-utils.h" +int am_pm_flag = 0; + +char * +nicetime (struct tm *tm) +{ + static char buf [20]; + + if (am_pm_flag){ + if (tm->tm_min) + strftime (buf, sizeof (buf), "%I:%M%p", tm); + else + strftime (buf, sizeof (buf), "%I%p", tm); + } else { + if (tm->tm_min) + strftime (buf, sizeof (buf), "%H:%M", tm); + else + strftime (buf, sizeof (buf), "%H", tm); + } + return buf; +} + void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area, int flags, GList *events, time_t start, time_t end) { int font_height; int x, y, max_y; - char buf[512]; + char buf [40]; int len; struct tm tm_start, tm_end; char *str; @@ -35,13 +57,12 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect tm_end = *localtime (&co->ev_end); str = ico->summary; - if (flags & VIEW_UTILS_DRAW_END) { - strftime (buf, 512, "%X-", &tm_start); - len = strlen (buf); - strftime (buf + len, 512 - len, "%X ", &tm_end); - } else - strftime (buf, 512, "%X ", &tm_start); - + strcpy (buf, nicetime (&tm_start)); + + if (flags & VIEW_UTILS_DRAW_END){ + strcat (buf, "-"); + strcat (buf, nicetime (&tm_end)); + } gdk_draw_string (window, widget->style->font, gc, -- cgit