diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2022-12-13 18:14:51 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2023-01-18 10:51:40 +0000 |
commit | 6179667d3d1aaba19e7a0fb1189a253d12f7cda8 (patch) | |
tree | baaa610d1424fd4b168123b5358f09b99f2592e9 /libmm-glib | |
parent | 7750e927f696632c3c94e5453b27f4ea928530e2 (diff) |
libmm-glib,common-helpers: avoid using g_time_zone_new_offset()
It requires newer glib than we do:
../libmm-glib/mm-common-helpers.c: In function ‘mm_new_iso8601_time’:
../libmm-glib/mm-common-helpers.c:1787:9: warning: ‘g_time_zone_new_offset’ is deprecated: Not available before 2.58 [-Wdeprecated-declarations]
1787 | tz = g_time_zone_new_offset (offset_minutes * 60);
| ^~
In file included from /usr/include/glib-2.0/glib/gdatetime.h:33:
/usr/include/glib-2.0/glib/gtimezone.h:67:25: note: declared here
67 | GTimeZone * g_time_zone_new_offset (gint32 seconds);
| ^~~~~~~~~~~~~~~~~~~~~~
Let's not use the routine with older versions of glib.
Diffstat (limited to 'libmm-glib')
-rw-r--r-- | libmm-glib/mm-common-helpers.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c index de49136d..b57cb205 100644 --- a/libmm-glib/mm-common-helpers.c +++ b/libmm-glib/mm-common-helpers.c @@ -1783,8 +1783,20 @@ mm_new_iso8601_time (guint year, if (have_offset) { g_autoptr(GTimeZone) tz = NULL; - +#if GLIB_CHECK_VERSION (2, 58, 0) + G_GNUC_BEGIN_IGNORE_DEPRECATIONS tz = g_time_zone_new_offset (offset_minutes * 60); + G_GNUC_END_IGNORE_DEPRECATIONS +#else + g_autofree gchar *identifier = NULL; + + identifier = g_strdup_printf ("%c%02u:%02u:00", + (offset_minutes >= 0) ? '+' : '-', + ABS (offset_minutes) / 60, + ABS (offset_minutes) % 60); + + tz = g_time_zone_new (identifier); +#endif dt = g_date_time_new (tz, year, month, day, hour, minute, second); } else dt = g_date_time_new_utc (year, month, day, hour, minute, second); |