tag: extract year from ID3v1 tag as GstDateTime instead of GDate

So we can signal properly that only the year is valid.
This commit is contained in:
Tim-Philipp Müller 2012-07-14 14:33:34 +01:00
parent eacb9ee554
commit a1d1bd0517
2 changed files with 13 additions and 10 deletions

View 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],

View 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);