From a1d1bd05170eb6168eb8d831b9e728c07f0cbd30 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 14 Jul 2012 14:33:34 +0100 Subject: [PATCH] tag: extract year from ID3v1 tag as GstDateTime instead of GDate So we can signal properly that only the year is valid. --- gst-libs/gst/tag/gstid3tag.c | 6 +++--- tests/check/libs/tag.c | 17 ++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/gst-libs/gst/tag/gstid3tag.c b/gst-libs/gst/tag/gstid3tag.c index e5b435e..1297490 100644 --- a/gst-libs/gst/tag/gstid3tag.c +++ b/gst-libs/gst/tag/gstid3tag.c @@ -269,10 +269,10 @@ gst_tag_list_new_from_id3v1 (const guint8 * data) year = strtoul (ystr, NULL, 10); g_free (ystr); if (year > 0) { - GDate *date = g_date_new_dmy (1, 1, year); + GstDateTime *dt = gst_date_time_new_y (year); - gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_DATE, date, NULL); - g_date_free (date); + gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_DATE_TIME, dt, NULL); + gst_date_time_unref (dt); } if (data[125] == 0 && data[126] != 0) { gst_tag_extract_id3v1_string (list, GST_TAG_COMMENT, (gchar *) & data[97], diff --git a/tests/check/libs/tag.c b/tests/check/libs/tag.c index 91d34a7..dfc30f4 100644 --- a/tests/check/libs/tag.c +++ b/tests/check/libs/tag.c @@ -638,8 +638,8 @@ GST_START_TEST (test_id3v1_utf8_tag) /* genre */ 0x11 }; + GstDateTime *dt; GstTagList *tags; - GDate *d; gchar *s; /* set this, to make sure UTF-8 strings are really interpreted properly @@ -669,12 +669,15 @@ GST_START_TEST (test_id3v1_utf8_tag) fail_unless_equals_string (s, "Best of (Prostě úžasný)"); g_free (s); - d = NULL; - fail_unless (gst_tag_list_get_date (tags, GST_TAG_DATE, &d)); - fail_unless (d != NULL); - fail_unless_equals_int (g_date_get_year (d), 2000); - g_date_free (d); - d = NULL; + dt = NULL; + fail_unless (gst_tag_list_get_date_time (tags, GST_TAG_DATE_TIME, &dt)); + fail_unless (dt != NULL); + fail_unless_equals_int (gst_date_time_get_year (dt), 2000); + fail_if (gst_date_time_has_month (dt)); + fail_if (gst_date_time_has_day (dt)); + fail_if (gst_date_time_has_time (dt)); + gst_date_time_unref (dt); + dt = NULL; gst_tag_list_free (tags); -- 2.7.4