[gnome-calendar] event: Switch to g_time_zone_new_identifier()
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] event: Switch to g_time_zone_new_identifier()
- Date: Fri, 26 Feb 2021 22:26:57 +0000 (UTC)
commit d1a0dbd8f58ad2ef4d5a6ada7a04452d66b3fb00
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Feb 26 19:21:14 2021 -0300
event: Switch to g_time_zone_new_identifier()
And add the relevant NULL checks here.
src/core/gcal-event.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/core/gcal-event.c b/src/core/gcal-event.c
index e44fa687..d92f01a0 100644
--- a/src/core/gcal-event.c
+++ b/src/core/gcal-event.c
@@ -175,7 +175,7 @@ get_timezone_from_ical (ECalComponentDateTime *comp)
if (g_str_has_prefix (real_tzid, LIBICAL_TZID_PREFIX))
real_tzid += strlen (LIBICAL_TZID_PREFIX);
- tz = g_time_zone_new (real_tzid);
+ tz = g_time_zone_new_identifier (real_tzid);
}
else if (zone)
{
@@ -184,14 +184,19 @@ get_timezone_from_ical (ECalComponentDateTime *comp)
offset = i_cal_timezone_get_utc_offset (zone, itt, NULL);
tzid = format_utc_offset (offset);
- tz = g_time_zone_new (tzid);
+ tz = g_time_zone_new_identifier (tzid);
}
else
{
tz = g_time_zone_new_utc ();
}
- g_assert (tz != NULL);
+ /*
+ * If tz is NULL, the timezone identifier is invalid. Fallback to UTC
+ * in this case.
+ */
+ if (!tz)
+ tz = g_time_zone_new_utc ();
GCAL_TRACE_MSG ("%s (%p)", g_time_zone_get_identifier (tz), tz);
@@ -1716,14 +1721,14 @@ gcal_event_get_original_timezones (GcalEvent *self,
if (g_strcmp0 (i_cal_property_get_x_name (property), "X-GNOME-CALENDAR-ORIGINAL-TZ-START") == 0)
{
value = i_cal_property_get_x (property);
- original_start_tz = g_time_zone_new (value);
+ original_start_tz = g_time_zone_new_identifier (value);
GCAL_TRACE_MSG ("Found X-GNOME-CALENDAR-ORIGINAL-TZ-START=%s", value);
}
else if (g_strcmp0 (i_cal_property_get_x_name (property), "X-GNOME-CALENDAR-ORIGINAL-TZ-END") == 0)
{
value = i_cal_property_get_x (property);
- original_end_tz = g_time_zone_new (value);
+ original_end_tz = g_time_zone_new_identifier (value);
GCAL_TRACE_MSG ("Found X-GNOME-CALENDAR-ORIGINAL-TZ-END=%s", value);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]