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
This commit is contained in:
Felipe Anibal
2024-11-19 18:10:02 +00:00
committed by Georges Basile Stavracas Neto
parent 69de2e6c3f
commit 3ce7575479
+16 -3
View File
@@ -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),