From 3ce757547975fb9eddce340b0e6be058ff0aa3ac Mon Sep 17 00:00:00 2001 From: Felipe Anibal Date: Tue, 12 Nov 2024 14:44:41 -0300 Subject: [PATCH] utils/date-time-utils: change date_time_from_icaltime to use tz offset Getting the time zone based on the location of the event doesn't work with virtual time zones, causing the offset to be incorrect on the import dialog. This changes the function to adjust the time zone of the GDateTime based on the offset from UTC, which should work for both virtual and real timezones. See #1243 --- src/utils/gcal-date-time-utils.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/utils/gcal-date-time-utils.c b/src/utils/gcal-date-time-utils.c index 09fd1e4e..df3ebad4 100644 --- a/src/utils/gcal-date-time-utils.c +++ b/src/utils/gcal-date-time-utils.c @@ -219,12 +219,25 @@ gcal_date_time_from_icaltime (const ICalTime *date) { g_autoptr (GTimeZone) tz = NULL; g_autoptr (GDateTime) dt = NULL; - const gchar *identifier; ICalTimezone *zone; zone = i_cal_time_get_timezone (date); - identifier = zone ? i_cal_timezone_get_location (zone) : NULL; - tz = identifier ? g_time_zone_new_identifier (identifier) : g_time_zone_new_utc (); + + if (zone) + { + g_autoptr (ICalTime) date_clone = NULL; + gint is_daylight; + gint offset; + + date_clone = i_cal_time_clone (date); + offset = i_cal_timezone_get_utc_offset (zone, date_clone, &is_daylight); + tz = g_time_zone_new_offset (offset); + } + else + { + tz = g_time_zone_new_utc (); + } + dt = g_date_time_new (tz, i_cal_time_get_year (date), i_cal_time_get_month (date),