gst-libs/gst/tag/gstvorbistag.c: Also accept partial dates with only year and month...
authorTim-Philipp Müller <tim@centricular.net>
Sat, 10 Mar 2007 12:18:58 +0000 (12:18 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Sat, 10 Mar 2007 12:18:58 +0000 (12:18 +0000)
Original commit message from CVS:
* gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_add):
Also accept partial dates with only year and month,
like 1999-12-00 (fixes #410396 even more).
* tests/check/libs/tag.c: (GST_START_TEST):
Add unit test for the above.

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

index 7f602a9..9772edc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2007-03-10  Tim-Philipp Müller  <tim at centricular dot net>
 
+       * gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_add):
+         Also accept partial dates with only year and month,
+         like 1999-12-00 (fixes #410396 even more).
+
+       * tests/check/libs/tag.c: (GST_START_TEST):
+         Add unit test for the above.
+
+2007-03-10  Tim-Philipp Müller  <tim at centricular dot net>
+
        * tests/check/elements/subparse.c: (GST_START_TEST),
        (subparse_suite):
          Add unit test for MPL2 subtitle format (#413799).
index e878d33..746c071 100644 (file)
@@ -254,10 +254,12 @@ gst_vorbis_tag_add (GstTagList * list, const gchar * tag, const gchar * value)
           }
         }
 
-        if (y != 0 && m == 0 && d == 0) {
-          /* accept dates of the form 2007-00-00 as 2007-01-01 */
-          m = 1;
-          d = 1;
+        /* accept dates like 2007-00-00 and 2007-05-00 */
+        if (y != 0) {
+          if (m == 0 && d == 0)
+            m = d = 1;
+          else if (m != 0 && d == 0)
+            d = 1;
         }
 
         /* date might be followed by a time */
index 5a799cd..61d8719 100644 (file)
@@ -530,6 +530,22 @@ GST_START_TEST (test_vorbis_tags)
     g_date_free (date);
     gst_tag_list_free (list);
   }
+
+  /* check date with valid month, but day of 00 */
+  {
+    GDate *date = NULL;
+
+    list = gst_tag_list_new ();
+    gst_vorbis_tag_add (list, "DATE", "1992-05-00");
+
+    fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
+    fail_unless (date != NULL);
+    fail_unless (g_date_get_year (date) == 1992);
+    fail_unless (g_date_get_month (date) == G_DATE_MAY);
+
+    g_date_free (date);
+    gst_tag_list_free (list);
+  }
 }
 
 GST_END_TEST;