gst-libs/gst/tag/gstvorbistag.c: Parse dates that are followed by a time as well...
authorTim-Philipp Müller <tim@centricular.net>
Mon, 25 Sep 2006 10:21:31 +0000 (10:21 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Mon, 25 Sep 2006 10:21:31 +0000 (10:21 +0000)
Original commit message from CVS:
* gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_add):
Parse dates that are followed by a time as well (#357532).
* tests/check/libs/tag.c: (test_vorbis_tags):
Add unit test for this.

ChangeLog
gst-libs/gst/tag/gstvorbistag.c
tests/check/libs/tag.c

index 78d23e7..a8d2211 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-25  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_add):
+         Parse dates that are followed by a time as well (#357532).
+
+       * tests/check/libs/tag.c: (test_vorbis_tags):
+         Add unit test for this.
+
 2006-09-23  Tim-Philipp Müller  <tim at centricular dot net>
 
        * gst/audioconvert/gstaudioconvert.c: (make_lossless_changes),
index 5473315..797785b 100644 (file)
@@ -244,7 +244,10 @@ gst_vorbis_tag_add (GstTagList * list, const gchar * tag, const gchar * value)
             d = strtoul (check, &check, 10);
           }
         }
-        if (*check == '\0' && y != 0 && g_date_valid_dmy (d, m, y)) {
+
+        /* date might be followed by a time */
+        if ((*check == '\0' || g_ascii_isspace (*check)) && y != 0 &&
+            g_date_valid_dmy (d, m, y)) {
           GDate *date;
 
           date = g_date_new_dmy (d, m, y);
index 63d6a13..2d82ba3 100644 (file)
@@ -497,6 +497,23 @@ GST_START_TEST (test_vorbis_tags)
 
     gst_buffer_unref (buf);
   }
+
+  /* check date with time */
+  {
+    GDate *date = NULL;
+
+    list = gst_tag_list_new ();
+    gst_vorbis_tag_add (list, "DATE", "2006-09-25 22:02:38");
+
+    fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
+    fail_unless (date != NULL);
+    fail_unless (g_date_get_day (date) == 25);
+    fail_unless (g_date_get_month (date) == G_DATE_SEPTEMBER);
+    fail_unless (g_date_get_year (date) == 2006);
+
+    g_date_free (date);
+    gst_tag_list_free (list);
+  }
 }
 
 GST_END_TEST;