From d6aec1acc3756685431e00cfb68d16cc527391b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 13 Feb 2011 22:56:15 +0000 Subject: [PATCH] gst-launch: pretty-print datetime tags --- tools/gst-launch.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/gst-launch.c b/tools/gst-launch.c index 10b7fae..bce9001 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -296,6 +296,31 @@ print_tag (const GstTagList * list, const gchar * tag, gpointer unused) } else { str = g_strdup ("NULL buffer"); } + } else if (gst_tag_get_type (tag) == GST_TYPE_DATE_TIME) { + GstDateTime *dt = NULL; + + gst_tag_list_get_date_time_index (list, tag, i, &dt); + if (gst_date_time_get_hour (dt) < 0) { + str = g_strdup_printf ("%02u-%02u-%04u", gst_date_time_get_day (dt), + gst_date_time_get_month (dt), gst_date_time_get_year (dt)); + } else { + gdouble tz_offset = gst_date_time_get_time_zone_offset (dt); + gchar tz_str[32]; + + if (tz_offset != 0.0) { + g_snprintf (tz_str, sizeof (tz_str), "(UTC %s%gh)", + (tz_offset > 0.0) ? "+" : "", tz_offset); + } else { + g_snprintf (tz_str, sizeof (tz_str), "(UTC)"); + } + + str = g_strdup_printf ("%04u-%02u-%02u %02u:%02u:%02u %s", + gst_date_time_get_year (dt), gst_date_time_get_month (dt), + gst_date_time_get_day (dt), gst_date_time_get_hour (dt), + gst_date_time_get_minute (dt), gst_date_time_get_second (dt), + tz_str); + } + gst_date_time_unref (dt); } else { str = g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i)); -- 2.7.4