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.
This commit is contained in:
committed by
Aleksander Morgado
parent
7750e927f6
commit
6179667d3d
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user