Commit 67eb5311 authored by Thiago Santos's avatar Thiago Santos
Browse files

tag: Update with latest datetime from core

Updates datetime functions to latest APIs in core
parent 83c14483
......@@ -1119,8 +1119,8 @@ parse_exif_ascii_tag (GstExifReader * reader, const GstExifTagMatch * tag,
if (sscanf (str, "%04d:%02d:%02d %02d:%02d:%02d", &year, &month, &day,
&hour, &minute, &second) > 0) {
gst_tag_list_add (reader->taglist, GST_TAG_MERGE_REPLACE, tag->gst_tag,
gst_date_time_new_local_time (year, month, day, hour, minute, second,
0), NULL);
gst_date_time_new_local_time (year, month, day, hour, minute,
second), NULL);
} else {
GST_WARNING ("Failed to parse %s into a datetime tag", str);
}
......
......@@ -1041,8 +1041,8 @@ read_one_tag (GstTagList * list, const gchar * tag, XmpTag * xmptag,
GST_LOG ("UTC timezone");
/* Having a Z at the end means UTC */
datetime = gst_date_time_new (year, month, day, hour, minute,
second, usecs, 0);
datetime = gst_date_time_new (0, year, month, day, hour, minute,
second + usecs / 1000000.0);
} else {
gchar *plus_pos = NULL;
gchar *neg_pos = NULL;
......@@ -1072,9 +1072,12 @@ read_one_tag (GstTagList * list, const gchar * tag, XmpTag * xmptag,
GST_LOG ("Timezone offset: %f (%d minutes)", gmt_offset / 60.0,
gmt_offset);
/* no way to know if it is DST or not */
datetime = gst_date_time_new (year, month, day, hour, minute,
second, usecs, gmt_offset / 60.0f);
datetime =
gst_date_time_new (gmt_offset / 60.0,
year, month, day, hour, minute,
second + usecs / ((gdouble) G_USEC_PER_SEC));
} else {
GST_WARNING ("Failed to parse timezone information");
}
......@@ -1416,7 +1419,7 @@ gst_value_serialize_xmp (const GValue * value)
(gint) g_date_get_day (date));
} else if (G_VALUE_TYPE (value) == GST_TYPE_DATE_TIME) {
gint year, month, day, hour, min, sec, microsec;
gint gmt_offset = 0;
gfloat gmt_offset = 0;
gint gmt_offset_hour, gmt_offset_min;
GstDateTime *datetime = (GstDateTime *) g_value_get_boxed (value);
......@@ -1427,14 +1430,14 @@ gst_value_serialize_xmp (const GValue * value)
min = gst_date_time_get_minute (datetime);
sec = gst_date_time_get_second (datetime);
microsec = gst_date_time_get_microsecond (datetime);
gmt_offset = (gint) (60 * gst_date_time_get_time_zone_offset (datetime));
gmt_offset = gst_date_time_get_time_zone_offset (datetime);
if (gmt_offset == 0) {
/* UTC */
return g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02d.%06dZ",
year, month, day, hour, min, sec, microsec);
} else {
gmt_offset_hour = ABS (gmt_offset) / 60;
gmt_offset_min = ABS (gmt_offset) % 60;
gmt_offset_hour = ABS (gmt_offset);
gmt_offset_min = (ABS (gmt_offset) - gmt_offset_hour) * 60;
return g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02d.%06d%c%02d:%02d",
year, month, day, hour, min, sec, microsec,
......
......@@ -1075,31 +1075,31 @@ GST_START_TEST (test_xmp_tags_serialization_deserialization)
g_value_unset (&value);
g_value_init (&value, GST_TYPE_DATE_TIME);
datetime = gst_date_time_new (2010, 6, 22, 12, 5, 10, 0, 0);
datetime = gst_date_time_new (0, 2010, 6, 22, 12, 5, 10);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
datetime = gst_date_time_new (2010, 6, 22, 12, 5, 10, 125, 0);
datetime = gst_date_time_new (0, 2010, 6, 22, 12, 5, 10.000125);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
datetime = gst_date_time_new (2010, 6, 22, 12, 5, 10, 1, 0);
datetime = gst_date_time_new (0, 2010, 6, 22, 12, 5, 10.000001);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
datetime = gst_date_time_new (2010, 6, 22, 12, 5, 10, 123456, 0);
datetime = gst_date_time_new (0, 2010, 6, 22, 12, 5, 10.123456);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
datetime = gst_date_time_new (2010, 6, 22, 12, 5, 10, 123456, -3);
datetime = gst_date_time_new (-3, 2010, 6, 22, 12, 5, 10.123456);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
datetime = gst_date_time_new (2010, 6, 22, 12, 5, 10, 123456, 5);
datetime = gst_date_time_new (5, 2010, 6, 22, 12, 5, 10.123456);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
datetime = gst_date_time_new_local_time (2010, 12, 2, 12, 5, 10, 43);
datetime = gst_date_time_new_local_time (2010, 12, 2, 12, 5, 10.000043);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
......@@ -1230,7 +1230,7 @@ GST_START_TEST (test_exif_multiple_tags)
GST_TAG_IMAGE_VERTICAL_PPI, 300.0, NULL);
g_value_init (&value, GST_TYPE_DATE_TIME);
datetime = gst_date_time_new_local_time (2010, 6, 22, 12, 5, 10, 0);
datetime = gst_date_time_new_local_time (2010, 6, 22, 12, 5, 10);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
gst_tag_list_add_value (taglist, GST_TAG_MERGE_APPEND, GST_TAG_DATE_TIME,
......@@ -1488,7 +1488,7 @@ GST_START_TEST (test_exif_tags_serialization_deserialization)
g_value_unset (&value);
g_value_init (&value, GST_TYPE_DATE_TIME);
datetime = gst_date_time_new_local_time (2010, 6, 22, 12, 5, 10, 0);
datetime = gst_date_time_new_local_time (2010, 6, 22, 12, 5, 10);
g_value_set_boxed (&value, datetime);
gst_date_time_unref (datetime);
do_simple_exif_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment