Skip to content

Commit

Permalink
datetime: Make use of new g_time_zone_new_identifier() that properly …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
sdroege committed Dec 7, 2020
1 parent 9f23808 commit cf0f39e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gst/gstdatetime.c
Expand Up @@ -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);
Expand Down

0 comments on commit cf0f39e

Please sign in to comment.