tag: extract year from ID3v1 tag as GstDateTime instead of GDate
authorTim-Philipp Müller <tim@centricular.net>
Sat, 14 Jul 2012 13:33:34 +0000 (14:33 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Sat, 14 Jul 2012 14:34:56 +0000 (15:34 +0100)
So we can signal properly that only the year is valid.

gst-libs/gst/tag/gstid3tag.c
tests/check/libs/tag.c

index e5b435e..1297490 100644 (file)
@@ -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],
index 91d34a7..dfc30f4 100644 (file)
@@ -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);