From 853e2bf67fb79da22386d5b1a79ada75024727ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 7 Jul 2012 19:43:50 +0100 Subject: [PATCH] datetime: when deserialising parse microseconds if available --- gst/gstdatetime.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gst/gstdatetime.c b/gst/gstdatetime.c index e1905af..b2e38a7 100644 --- a/gst/gstdatetime.c +++ b/gst/gstdatetime.c @@ -727,8 +727,10 @@ gst_date_time_to_iso8601_string (GstDateTime * datetime) GstDateTime * gst_date_time_new_from_iso8601_string (const gchar * string) { - gint year = -1, month = -1, day = -1, hour = -1, minute = -1, second = -1; + gint year = -1, month = -1, day = -1, hour = -1, minute = -1; + gdouble second = -1.0; gfloat tzoffset = 0.0; + guint64 usecs; gint len, ret; len = strlen (string); @@ -783,6 +785,18 @@ gst_date_time_new_from_iso8601_string (const gchar * string) * will still attempt to parse any timezone information */ if (second > 59) { second = -1.0; + } else { + /* microseconds */ + if (*string == '.' || *string == ',') { + const gchar *usec_start = string + 1; + guint digits; + + usecs = g_ascii_strtoull (string + 1, (gchar **) & string, 10); + if (usecs != G_MAXUINT64 && string > usec_start) { + digits = (guint) (string - usec_start); + second += (gdouble) usecs / pow (10.0, digits); + } + } } } -- 2.7.4