From cf0f39efe80187b728fe07807647d22afdbc871f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 25 Nov 2020 14:02:23 +0200 Subject: [PATCH] datetime: Make use of new g_time_zone_new_identifier() that properly handles errors g_time_zone_new() returns UTC if it fails to parse the timezone identifier, which is rather suboptimal and causes wrong datetimes to be created silently. Part-of: --- gst/gstdatetime.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gst/gstdatetime.c b/gst/gstdatetime.c index f49132b81c..2b8c20ea6a 100644 --- a/gst/gstdatetime.c +++ b/gst/gstdatetime.c @@ -763,7 +763,15 @@ gst_date_time_new (gfloat tzoffset, gint year, gint month, gint day, gint hour, g_snprintf (buf, 6, "%c%02d%02d", tzoffset >= 0 ? '+' : '-', tzhour, tzminute); +#if GLIB_CHECK_VERSION (2, 67, 1) + /* g_time_zone_new() would always return UTC if the identifier can't be + * parsed, which is rather suboptimal. */ + tz = g_time_zone_new_identifier (buf); + if (!tz) + return NULL; +#else tz = g_time_zone_new (buf); +#endif fields = gst_date_time_check_fields (&year, &month, &day, &hour, &minute, &seconds);