From 6acfed92c150de3a36c0fe4b4753040fdd96fa3e Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 2 Feb 2022 15:34:03 +0100 Subject: [PATCH] calendar-server: Read timezone from the calendar, not its timezone cache The calendar's timezone cache holds only timezones already received or added to the calendar, thus when asking it for a timezone for "the first time", it returns NULL and a wrong timezone is used instead. The get_timezone() does not do any I/O when the timezone is already cached on the client side, thus it's fine to use it. This could exhibit with non-recurring events, which use custom time zones, in which case the event is shown in a wrong time. (cherry picked from commit 42b3b8546066d27d51997c34ba7ca54c00275296) Part-of: --- .../gnome-shell-calendar-server.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/calendar-server/gnome-shell-calendar-server.c b/src/calendar-server/gnome-shell-calendar-server.c index 5d15e2ae6..f1980c633 100644 --- a/src/calendar-server/gnome-shell-calendar-server.c +++ b/src/calendar-server/gnome-shell-calendar-server.c @@ -123,7 +123,6 @@ get_time_from_property (ECalClient *cal, { ICalProperty *prop; ICalTime *itt; - ICalParameter *param; ICalTimezone *timezone = NULL; prop = i_cal_component_get_first_property (icomp, prop_kind); @@ -132,17 +131,24 @@ get_time_from_property (ECalClient *cal, itt = get_prop_func (prop); - param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER); - if (param) - timezone = e_timezone_cache_get_timezone (E_TIMEZONE_CACHE (cal), i_cal_parameter_get_tzid (param)); - else if (i_cal_time_is_utc (itt)) + if (i_cal_time_is_utc (itt)) timezone = i_cal_timezone_get_utc_timezone (); else + { + ICalParameter *param; + + param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER); + if (param && !e_cal_client_get_timezone_sync (cal, i_cal_parameter_get_tzid (param), &timezone, NULL, NULL)) + print_debug ("Failed to get timezone '%s'\n", i_cal_parameter_get_tzid (param)); + + g_clear_object (¶m); + } + + if (timezone == NULL) timezone = default_zone; i_cal_time_set_timezone (itt, timezone); - g_clear_object (¶m); g_clear_object (&prop); *out_itt = itt;