[gnome-control-center/gbsneto/timezone] datetime: Use g_time_zone_new_identifier
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/timezone] datetime: Use g_time_zone_new_identifier
- Date: Tue, 23 Feb 2021 13:17:50 +0000 (UTC)
commit ad2878c126905c2a83dede8c277b082c14608a9a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Feb 23 10:13:56 2021 -0300
datetime: Use g_time_zone_new_identifier
g_time_zone_new() is deprecated in favour of g_time_zone_new_identifier().
g_time_zone_new_identifier() returns NULL if no matching identifier is
found, so warn and fallback to UTC in that case.
panels/datetime/cc-datetime-panel.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 33a975941..093cc4ae5 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -518,7 +518,13 @@ location_changed_cb (CcDateTimePanel *self,
self->current_location = location;
- timezone = g_time_zone_new (location->zone);
+ timezone = g_time_zone_new_identifier (location->zone);
+ if (!timezone)
+ {
+ g_warning ("Could not fine timezone \"%s\", using UTC instead", location->zone);
+ timezone = g_time_zone_new_utc ();
+ }
+
old_date = self->date;
self->date = g_date_time_to_timezone (old_date, timezone);
cc_time_editor_set_time (CC_TIME_EDITOR (self->time_editor),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]