diff options
author | Damon Chaplin <damon@ximian.com> | 2001-07-03 12:21:37 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2001-07-03 12:21:37 +0800 |
commit | 642d32d63f226cd1ba049a9d979132e1a1cef94d (patch) | |
tree | be4ef8fb72ca41391007554a6cbe97af41533555 /calendar/cal-util | |
parent | bacd3a85a434032316b3e63b95282175ce2b0659 (diff) | |
download | gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.gz gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.zst gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.zip |
cal-client/cal-client.[hc] cal-util/cal-component.c
2001-07-03 Damon Chaplin <damon@ximian.com>
* cal-client/cal-client.[hc]
* cal-util/cal-component.c
* cal-util/cal-recur.[hc]
* cal-util/test-recur.c
* cal-util/timeutil.c
* gui/calendar-config.c
* gui/calendar-model.[hc]
* gui/comp-util.[hc]
* gui/e-calendar-table.c
* gui/e-day-view-main-item.c
* gui/e-day-view-top-item.c
* gui/e-day-view.[hc]
* gui/e-itip-control.c
* gui/e-timezone-entry.[hc]
* gui/e-week-view.[hc]
* gui/gnome-cal.[hc]
* gui/goto.c
* gui/tag-calendar.[hc]
* gui/dialogs/cal-prefs-dialog.c
* gui/dialogs/comp-editor-page.[hc]
* gui/dialogs/comp-editor-util.[hc]
* gui/dialogs/comp-editor.c
* gui/dialogs/e-timezone-dialog.[hc]
* gui/dialogs/event-page.c
* gui/dialogs/meeting-page.c
* gui/dialogs/recurrence-page.c
* gui/dialogs/task-details-page.c
* gui/dialogs/task-details-page.glade
* gui/dialogs/task-page.c
* idl/evolution-calendar.idl
* pcs/cal-backend-file.c
* pcs/cal-backend.c
* pcs/cal-backend.h
* pcs/cal.c
* pcs/query.c: timezone changes everywhere. There's still quite a
few things to update, and its not working well at present.
svn path=/trunk/; revision=10729
Diffstat (limited to 'calendar/cal-util')
-rw-r--r-- | calendar/cal-util/cal-component.c | 13 | ||||
-rw-r--r-- | calendar/cal-util/cal-recur.c | 62 | ||||
-rw-r--r-- | calendar/cal-util/cal-recur.h | 11 | ||||
-rw-r--r-- | calendar/cal-util/test-recur.c | 6 | ||||
-rw-r--r-- | calendar/cal-util/timeutil.c | 17 |
5 files changed, 77 insertions, 32 deletions
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index 36c6408d59..2669dc5562 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -883,7 +883,7 @@ ensure_mandatory_properties (CalComponent *comp) struct icaltimetype t; tim = time (NULL); - t = icaltime_from_timet (tim, FALSE); + t = icaltime_from_timet_with_zone (tim, FALSE, icaltimezone_get_utc_timezone ()); priv->dtstamp = icalproperty_new_dtstamp (t); icalcomponent_add_property (priv->icalcomp, priv->dtstamp); @@ -1822,8 +1822,12 @@ get_datetime (struct datetime *datetime, } else dt->value = NULL; + /* If the icaltimetype has is_utc set, we set "UTC" as the TZID. + This makes the timezone code simpler. */ if (datetime->tzid_param) dt->tzid = icalparameter_get_tzid (datetime->tzid_param); + else if (dt->value && dt->value->is_utc) + dt->tzid = "UTC"; else dt->tzid = NULL; } @@ -1853,6 +1857,10 @@ set_datetime (CalComponent *comp, struct datetime *datetime, g_return_if_fail (dt->value != NULL); + /* If the TZID is set to "UTC", we set the is_utc flag. */ + if (dt->tzid && !strcmp (dt->tzid, "UTC")) + dt->value->is_utc = 1; + if (datetime->prop) (* prop_set_func) (datetime->prop, *dt->value); else { @@ -1860,7 +1868,8 @@ set_datetime (CalComponent *comp, struct datetime *datetime, icalcomponent_add_property (priv->icalcomp, datetime->prop); } - if (dt->tzid) { + /* If the TZID is set to "UTC", we don't want to save the TZID. */ + if (dt->tzid && strcmp (dt->tzid, "UTC")) { g_assert (datetime->prop != NULL); if (datetime->tzid_param) diff --git a/calendar/cal-util/cal-recur.c b/calendar/cal-util/cal-recur.c index 9dcd1579a9..1e21f3109c 100644 --- a/calendar/cal-util/cal-recur.c +++ b/calendar/cal-util/cal-recur.c @@ -257,7 +257,9 @@ static void cal_recur_generate_instances_of_rule (CalComponent *comp, time_t start, time_t end, CalRecurInstanceFn cb, - gpointer cb_data); + gpointer cb_data, + CalRecurResolveTimezoneFn tz_cb, + gpointer tz_cb_data); static CalRecurrence * cal_recur_from_icalproperty (icalproperty *prop, gboolean exception); @@ -465,11 +467,15 @@ static gint cal_obj_date_only_compare_func (const void *arg1, static gboolean cal_recur_ensure_end_dates (CalComponent *comp, - gboolean refresh); + gboolean refresh, + CalRecurResolveTimezoneFn tz_cb, + gpointer tz_cb_data); static gboolean cal_recur_ensure_rule_end_date (CalComponent *comp, icalproperty *prop, gboolean exception, - gboolean refresh); + gboolean refresh, + CalRecurResolveTimezoneFn tz_cb, + gpointer tz_cb_data); static gboolean cal_recur_ensure_rule_end_date_cb (CalComponent *comp, time_t instance_start, time_t instance_end, @@ -598,7 +604,9 @@ cal_recur_generate_instances (CalComponent *comp, time_t start, time_t end, CalRecurInstanceFn cb, - gpointer cb_data) + gpointer cb_data, + CalRecurResolveTimezoneFn tz_cb, + gpointer tz_cb_data) { #if 0 g_print ("In cal_recur_generate_instances comp: %p\n", comp); @@ -606,7 +614,7 @@ cal_recur_generate_instances (CalComponent *comp, g_print (" end : %li - %s", end, ctime (&end)); #endif cal_recur_generate_instances_of_rule (comp, NULL, start, end, - cb, cb_data); + cb, cb_data, tz_cb, tz_cb_data); } @@ -630,7 +638,9 @@ cal_recur_generate_instances_of_rule (CalComponent *comp, time_t start, time_t end, CalRecurInstanceFn cb, - gpointer cb_data) + gpointer cb_data, + CalRecurResolveTimezoneFn tz_cb, + gpointer tz_cb_data) { CalComponentDateTime dtstart, dtend; time_t dtstart_time, dtend_time; @@ -640,6 +650,7 @@ cal_recur_generate_instances_of_rule (CalComponent *comp, CalObjTime chunk_start, chunk_end; gint days, seconds, year; gboolean single_rule; + icaltimezone *start_zone = NULL, *end_zone = NULL; g_return_if_fail (comp != NULL); g_return_if_fail (cb != NULL); @@ -657,15 +668,25 @@ cal_recur_generate_instances_of_rule (CalComponent *comp, goto out; } - dtstart_time = icaltime_as_timet (*dtstart.value); + if (dtstart.tzid && tz_cb) + start_zone = (*tz_cb) (dtstart.tzid, tz_cb_data); + if (dtend.tzid && tz_cb) + end_zone = (*tz_cb) (dtend.tzid, tz_cb_data); + + dtstart_time = icaltime_as_timet_with_zone (*dtstart.value, + start_zone); if (start == -1) start = dtstart_time; /* FIXME: DURATION could be used instead, couldn't it? - Damon */ - if (dtend.value) - dtend_time = icaltime_as_timet (*dtend.value); - else - dtend_time = time_day_end (dtstart_time); + if (!dtend.value) { + *dtend.value = *dtstart.value; + dtend.value->hour = 0; + dtend.value->minute = 0; + dtend.value->second = 0; + icaltime_adjust (dtend.value, 1, 0, 0, 0); + } + dtend_time = icaltime_as_timet_with_zone (*dtend.value, end_zone); /* If there is no recurrence, just call the callback if the event intersects the given interval. */ @@ -690,7 +711,7 @@ cal_recur_generate_instances_of_rule (CalComponent *comp, single_rule = FALSE; /* Make sure all the enddates for the rules are set. */ - cal_recur_ensure_end_dates (comp, FALSE); + cal_recur_ensure_end_dates (comp, FALSE, tz_cb, tz_cb_data); cal_component_get_rrule_property_list (comp, &rrules); cal_component_get_rdate_list (comp, &rdates); @@ -3576,6 +3597,7 @@ cal_object_time_from_time (CalObjTime *cotime, time_t tmp_time_t; tmp_time_t = t; + /* FIXME */ tmp_tm = localtime (&tmp_time_t); cotime->year = tmp_tm->tm_year + 1900; @@ -3619,7 +3641,9 @@ cal_obj_time_to_string (CalObjTime *cotime) or EXRULE. */ static gboolean cal_recur_ensure_end_dates (CalComponent *comp, - gboolean refresh) + gboolean refresh, + CalRecurResolveTimezoneFn tz_cb, + gpointer tz_cb_data) { GSList *rrules, *exrules, *elem; gboolean changed = FALSE; @@ -3628,14 +3652,16 @@ cal_recur_ensure_end_dates (CalComponent *comp, cal_component_get_rrule_property_list (comp, &rrules); for (elem = rrules; elem; elem = elem->next) { changed |= cal_recur_ensure_rule_end_date (comp, elem->data, - FALSE, refresh); + FALSE, refresh, + tz_cb, tz_cb_data); } /* Do the EXRULEs. */ cal_component_get_exrule_property_list (comp, &exrules); for (elem = exrules; elem; elem = elem->next) { changed |= cal_recur_ensure_rule_end_date (comp, elem->data, - TRUE, refresh); + TRUE, refresh, + tz_cb, tz_cb_data); } return changed; @@ -3654,7 +3680,9 @@ static gboolean cal_recur_ensure_rule_end_date (CalComponent *comp, icalproperty *prop, gboolean exception, - gboolean refresh) + gboolean refresh, + CalRecurResolveTimezoneFn tz_cb, + gpointer tz_cb_data) { struct icalrecurrencetype rule; CalRecurEnsureEndDateData cb_data; @@ -3680,7 +3708,7 @@ cal_recur_ensure_rule_end_date (CalComponent *comp, cb_data.instances = 0; cal_recur_generate_instances_of_rule (comp, prop, -1, -1, cal_recur_ensure_rule_end_date_cb, - &cb_data); + &cb_data, tz_cb, tz_cb_data); /* Store the end date in the "X-EVOLUTION-ENDDATE" parameter of the rule. */ diff --git a/calendar/cal-util/cal-recur.h b/calendar/cal-util/cal-recur.h index ad80c3ce1b..921a230de4 100644 --- a/calendar/cal-util/cal-recur.h +++ b/calendar/cal-util/cal-recur.h @@ -35,6 +35,9 @@ typedef gboolean (* CalRecurInstanceFn) (CalComponent *comp, time_t instance_end, gpointer data); +typedef icaltimezone* (* CalRecurResolveTimezoneFn) (const char *tzid, + gpointer data); + /* * Calls the given callback function for each occurrence of the event that * intersects the range between the given start and end times (the end time is @@ -45,12 +48,18 @@ typedef gboolean (* CalRecurInstanceFn) (CalComponent *comp, * * Both start and end can be -1, in which case we start at the events first * instance and continue until it ends, or forever if it has no enddate. + * + * The tz_cb is used to resolve references to timezones. It is passed a TZID + * and should return the icaltimezone* corresponding to that TZID. We need to + * do this as we access timezones in different ways on the client & server. */ void cal_recur_generate_instances (CalComponent *comp, time_t start, time_t end, CalRecurInstanceFn cb, - gpointer cb_data); + gpointer cb_data, + CalRecurResolveTimezoneFn tz_cb, + gpointer tz_cb_data); END_GNOME_DECLS diff --git a/calendar/cal-util/test-recur.c b/calendar/cal-util/test-recur.c index 4fee2d23a9..213017ea0e 100644 --- a/calendar/cal-util/test-recur.c +++ b/calendar/cal-util/test-recur.c @@ -156,10 +156,12 @@ generate_occurrences (icalcomponent *icalcomp) in one of the calendar views. */ #if 0 cal_recur_generate_instances (comp, 982022400, 982108800, - occurrence_cb, &occurrences); + occurrence_cb, &occurrences, + NULL, NULL); #else cal_recur_generate_instances (comp, -1, -1, - occurrence_cb, &occurrences); + occurrence_cb, &occurrences, + NULL, NULL); #endif /* Print the component again so we can see the diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c index 07936950c0..3bb254dbf7 100644 --- a/calendar/cal-util/timeutil.c +++ b/calendar/cal-util/timeutil.c @@ -11,6 +11,7 @@ #include <string.h> #include <ctype.h> #include <glib.h> +#include <ical.h> #include "timeutil.h" @@ -39,8 +40,8 @@ isodate_from_time_t (time_t t) struct tm *tm; char isotime[40]; - tm = localtime (&t); - strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%S", tm); + tm = gmtime (&t); + strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%SZ", tm); return g_strdup (isotime); } @@ -51,6 +52,7 @@ isodate_from_time_t (time_t t) * Converts an ISO 8601 time string into a time_t value. * * Return value: Time_t corresponding to the specified ISO string. + * Note that we only allow UTC times at present. **/ time_t time_from_isodate (const char *str) @@ -59,6 +61,7 @@ time_from_isodate (const char *str) struct tm my_tm; time_t t; int i; + char *old_tz; g_return_val_if_fail (str != NULL, -1); @@ -93,16 +96,10 @@ time_from_isodate (const char *str) my_tm.tm_isdst = -1; + old_tz = set_tz ("UTC"); t = mktime (&my_tm); + unset_tz (old_tz); - if (len == 16) { -#if defined(HAVE_TM_GMTOFF) - t += my_tm.tm_gmtoff; -#elif defined(HAVE_TIMEZONE) - t -= timezone; -#endif - } - return t; } |