[PATCH 3/6] core: added grl_media_set_date_from_iso8601()
- From: Guillaume Emont <guijemont igalia com>
- To: grilo-list gnome org
- Cc: Guillaume Emont <guijemont igalia com>
- Subject: [PATCH 3/6] core: added grl_media_set_date_from_iso8601()
- Date: Wed, 22 Jun 2011 19:07:53 +0200
---
src/data/grl-media.c | 23 +++++++++++++++++++++++
src/data/grl-media.h | 2 ++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/data/grl-media.c b/src/data/grl-media.c
index eea3602..9d7a50b 100644
--- a/src/data/grl-media.c
+++ b/src/data/grl-media.c
@@ -686,6 +686,29 @@ grl_media_set_date (GrlMedia *media, const GDateTime *date)
date);
}
+gboolean
+grl_media_set_date_from_iso8601 (GrlMedia *media, const gchar *date)
+{
+ GTimeVal t = { 0, };
+
+ if (g_time_val_from_iso8601 (date, &t)) {
+ GDateTime *date_time;
+
+ /* work around https://bugzilla.gnome.org/show_bug.cgi?id=650968 */
+ if (t.tv_sec == 0 && t.tv_usec == 0)
+ return FALSE;
+
+ date_time = g_date_time_new_from_timeval_utc (&t);
+
+ grl_media_set_date (media, date_time);
+ g_date_time_unref (date_time);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/**
* grl_media_set_creation_date:
* @media: the media
diff --git a/src/data/grl-media.h b/src/data/grl-media.h
index b23422e..626d765 100644
--- a/src/data/grl-media.h
+++ b/src/data/grl-media.h
@@ -121,6 +121,8 @@ void grl_media_set_duration (GrlMedia *media, gint duration);
void grl_media_set_date (GrlMedia *media, const GDateTime *date);
+gboolean grl_media_set_date_from_iso8601 (GrlMedia *media, const gchar *date);
+
void grl_media_set_creation_date (GrlMedia *media, const GDateTime *creation_date);
void grl_media_set_mime (GrlMedia *media, const gchar *mime);
--
1.7.4.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]