From 4462906be41fc5843ce0d9570387244ac44b107e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 10 Mar 2007 12:18:58 +0000 Subject: [PATCH] gst-libs/gst/tag/gstvorbistag.c: Also accept partial dates with only year and month, like 1999-12-00 (fixes #410396 e... 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 | 9 +++++++++ gst-libs/gst/tag/gstvorbistag.c | 10 ++++++---- tests/check/libs/tag.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f602a9dda..9772edc8c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-03-10 Tim-Philipp Müller + + * 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 * tests/check/elements/subparse.c: (GST_START_TEST), diff --git a/gst-libs/gst/tag/gstvorbistag.c b/gst-libs/gst/tag/gstvorbistag.c index e878d33a1b..746c071d0b 100644 --- a/gst-libs/gst/tag/gstvorbistag.c +++ b/gst-libs/gst/tag/gstvorbistag.c @@ -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 */ diff --git a/tests/check/libs/tag.c b/tests/check/libs/tag.c index 5a799cd309..61d871949b 100644 --- a/tests/check/libs/tag.c +++ b/tests/check/libs/tag.c @@ -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;