From 787e58107c69d5a9d88f372bd9856fc6088609d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 25 Sep 2006 10:21:31 +0000 Subject: [PATCH] gst-libs/gst/tag/gstvorbistag.c: Parse dates that are followed by a time as well (#357532). 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 | 8 ++++++++ gst-libs/gst/tag/gstvorbistag.c | 5 ++++- tests/check/libs/tag.c | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 78d23e79f1..a8d2211120 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-09-25 Tim-Philipp Müller + + * 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 * gst/audioconvert/gstaudioconvert.c: (make_lossless_changes), diff --git a/gst-libs/gst/tag/gstvorbistag.c b/gst-libs/gst/tag/gstvorbistag.c index 547331564f..797785b53a 100644 --- a/gst-libs/gst/tag/gstvorbistag.c +++ b/gst-libs/gst/tag/gstvorbistag.c @@ -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); diff --git a/tests/check/libs/tag.c b/tests/check/libs/tag.c index 63d6a13b88..2d82ba355d 100644 --- a/tests/check/libs/tag.c +++ b/tests/check/libs/tag.c @@ -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;