diff options
Diffstat (limited to 'calendar/cal-util/calobj.c')
-rw-r--r-- | calendar/cal-util/calobj.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 5ef1f1bb5f..4a3afd81ec 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -1178,48 +1178,53 @@ is_date_in_list (GList *list, struct tm *date) return 0; } - -/* FIXME: Doesn't work with events >= 1 day. */ -static int +/* Generates an event instance based on the reference time */ +static gboolean generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure) { - struct tm dt_start, dt_end, ref; - time_t s_t, e_t; - - dt_start = *localtime (&ico->dtstart); - dt_end = *localtime (&ico->dtend); - ref = *localtime (&reference); + time_t offset; + struct tm tm_start, ref; + time_t start, end; - dt_start.tm_mday = ref.tm_mday; - dt_start.tm_mon = ref.tm_mon; - dt_start.tm_year = ref.tm_year; + offset = ico->dtend - ico->dtstart; - dt_end.tm_mday = ref.tm_mday; - dt_end.tm_mon = ref.tm_mon; - dt_end.tm_year = ref.tm_year; + tm_start = *localtime (&ico->dtstart); + ref = *localtime (&reference); + tm_start.tm_mday = ref.tm_mday; + tm_start.tm_mon = ref.tm_mon; + tm_start.tm_year = ref.tm_year; - if (ref.tm_isdst > dt_start.tm_isdst){ - dt_start.tm_hour--; - dt_end.tm_hour--; - } else if (ref.tm_isdst < dt_start.tm_isdst){ - dt_start.tm_hour++; - dt_end.tm_hour++; + start = mktime (&tm_start); + if (start == -1) { + g_message ("generate(): Produced invalid start date!"); + return FALSE; } - s_t = mktime (&dt_start); - - if (ico->exdate && is_date_in_list (ico->exdate, &dt_start)) - return 1; + end = start + offset; - e_t = mktime (&dt_end); +#if 0 + /* FIXME: I think this is not needed, since we are offsetting by full day values, + * and the times should remain the same --- if you have a daily appointment + * at 18:00, it is always at 18:00 even during daylight savings. + * + * However, what should happen on the exact change-of-savings day with + * appointments in the early morning hours? + */ - if ((s_t == -1) || (e_t == -1)) { - g_warning ("Produced invalid dates!\n"); - return 0; + if (ref.tm_isdst > tm_start.tm_isdst) { + tm_start.tm_hour--; + tm_end.tm_hour--; + } else if (ref.tm_isdst < tm_start.tm_isdst) { + tm_start.tm_hour++; + tm_end.tm_hour++; } +#endif + + if (ico->exdate && is_date_in_list (ico->exdate, &tm_start)) + return TRUE; - return (*cb) (ico, s_t, e_t, closure); + return (*cb) (ico, start, end, closure); } int |