[gnome-panel] clock: switch to g_time_zone_new_identifier



commit 264641a95283b8d394c61a7aa46453f8e3b12377
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Mar 14 16:41:30 2021 +0200

    clock: switch to g_time_zone_new_identifier
    
    g_time_zone_new is deprecated.

 configure.ac                        |  2 +-
 modules/clock/clock-location-tile.c |  9 ++++++++-
 modules/clock/clock-location.c      | 14 ++++++++++++--
 3 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4ef284a35..9edc052eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,7 +124,7 @@ AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
 LIBGNOME_DESKTOP_REQUIRED=2.91.0
 GDK_PIXBUF_REQUIRED=2.26.0
 PANGO_REQUIRED=1.15.4
-GLIB_REQUIRED=2.45.3
+GLIB_REQUIRED=2.67.1
 GTK_REQUIRED=3.22.0
 LIBWNCK_REQUIRED=3.4.6
 LIBGNOME_MENU_REQUIRED=3.7.90
diff --git a/modules/clock/clock-location-tile.c b/modules/clock/clock-location-tile.c
index 6aaabc34e..e4de503bd 100644
--- a/modules/clock/clock-location-tile.c
+++ b/modules/clock/clock-location-tile.c
@@ -505,7 +505,14 @@ convert_time_to_str (time_t now, GDesktopClockFormat clock_format, const char *t
                format = _("%H:%M");
        }
 
-       tz = g_time_zone_new (timezone);
+       tz = g_time_zone_new_identifier (timezone);
+
+       if (tz == NULL) {
+               g_warning ("Invalid timezone identifier - %s, falling back to UTC!",
+                          timezone);
+
+               tz = g_time_zone_new_utc ();
+       }
 
        utc = g_date_time_new_from_unix_utc (now);
        local = g_date_time_to_timezone (utc, tz);
diff --git a/modules/clock/clock-location.c b/modules/clock/clock-location.c
index ed71f5375..c19531ec0 100644
--- a/modules/clock/clock-location.c
+++ b/modules/clock/clock-location.c
@@ -265,15 +265,25 @@ GDateTime *
 clock_location_localtime (ClockLocation *loc)
 {
        GWeatherTimezone *wtz;
+       const char *tzid;
        GTimeZone *tz;
        GDateTime *dt;
 
        wtz = clock_location_get_gweather_timezone (loc);
+       tzid = gweather_timezone_get_tzid (wtz);
 
-       tz = g_time_zone_new (gweather_timezone_get_tzid (wtz));
-       dt = g_date_time_new_now (tz);
+       tz = g_time_zone_new_identifier (tzid);
+
+       if (tz == NULL) {
+               g_warning ("Invalid timezone identifier - %s, falling back to UTC!",
+                          tzid);
 
+               tz = g_time_zone_new_utc ();
+       }
+
+       dt = g_date_time_new_now (tz);
        g_time_zone_unref (tz);
+
        return dt;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]