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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/706>
This commit is contained in:
Sebastian Dröge 2020-11-25 14:02:23 +02:00
parent 9f23808b55
commit cf0f39efe8

View file

@ -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);