diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/gnome-cal.c | 21 | ||||
-rw-r--r-- | calendar/gui/year-view.c | 23 |
2 files changed, 23 insertions, 21 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 24c854ee5c..a54d4e4a78 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -335,19 +335,20 @@ static int mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c) { GtkCalendar *gtk_cal = c; - struct tm *tm_s; + struct tm tm_s; int days, day; + time_t t, day_end; - tm_s = localtime (&start); - days = difftime (end, start) / (60*60*24); - - for (day = 0; day <= days; day++){ - time_t new = mktime (tm_s); - struct tm *tm_day; + tm_s = *localtime (&start); + day_end = time_end_of_day (end); + + for (t = start; t <= day_end; t += 60*60*24){ + time_t new = mktime (&tm_s); + struct tm tm_day; - tm_day = localtime (&new); - gtk_calendar_mark_day (gtk_cal, tm_day->tm_mday); - tm_s->tm_mday++; + tm_day = *localtime (&new); + gtk_calendar_mark_day (gtk_cal, tm_day.tm_mday); + tm_s.tm_mday++; } return TRUE; } diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c index bc03b4f36e..e8cb12feb3 100644 --- a/calendar/gui/year-view.c +++ b/calendar/gui/year-view.c @@ -168,20 +168,21 @@ static void year_view_mark_day (iCalObject *ical, time_t start, time_t end, void *closure) { GncalYearView *yview = (GncalYearView *) closure; - struct tm *tm_s; + struct tm tm_s; int days, day; - - tm_s = localtime (&start); - days = difftime (end, start) / (60*60*24); + time_t t, day_end; + + tm_s = *localtime (&start); + day_end = time_end_of_day (end); - for (day = 0; day <= days; day++){ - time_t new = mktime (tm_s); - struct tm *tm_day; + for (t = start; t <= day_end; t+= 60*60*24){ + time_t new = mktime (&tm_s); + struct tm tm_day; - tm_day = localtime (&new); - gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day->tm_mon]), - tm_day->tm_mday); - tm_s->tm_mday++; + tm_day = *localtime (&new); + gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day.tm_mon]), + tm_day.tm_mday); + tm_s.tm_mday++; } } |