[PATCH 05/11] flickr: updated to new date format
- From: Guillaume Emont <guijemont igalia com>
- To: grilo-list gnome org
- Cc: Guillaume Emont <guijemont igalia com>
- Subject: [PATCH 05/11] flickr: updated to new date format
- Date: Wed, 22 Jun 2011 19:13:50 +0200
---
src/media/flickr/gflickr.c | 15 +++++++++++++++
src/media/flickr/gflickr.h | 2 ++
src/media/flickr/grl-flickr.c | 9 +++++++--
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/media/flickr/gflickr.c b/src/media/flickr/gflickr.c
index 695c7dc..449201f 100644
--- a/src/media/flickr/gflickr.c
+++ b/src/media/flickr/gflickr.c
@@ -1194,3 +1194,18 @@ g_flickr_auth_checkToken (GFlickr *f,
read_url_async (f, request, gfd);
g_free (request);
}
+
+GDateTime *
+g_flickr_parse_date (const gchar *date)
+{
+ /* See http://www.flickr.com/services/api/misc.dates.html */
+ guint year, month, day, hours, minutes;
+ gdouble seconds;
+
+ sscanf (date, "%u-%u-%u %u:%u:%lf",
+ &year, &month, &day, &hours, &minutes, &seconds);
+
+ /* The date we get from flickr is expressed in the timezone of the camera,
+ * which we cannot know, so we just go with utc */
+ return g_date_time_new_utc (year, month, day, hours, minutes, seconds);
+}
diff --git a/src/media/flickr/gflickr.h b/src/media/flickr/gflickr.h
index dd583d8..73c3f57 100644
--- a/src/media/flickr/gflickr.h
+++ b/src/media/flickr/gflickr.h
@@ -152,4 +152,6 @@ g_flickr_auth_checkToken (GFlickr *f,
GFlickrHashTableCb callback,
gpointer user_data);
+GDateTime *
+g_flickr_parse_date (const gchar *date);
#endif /* _G_FLICKR_H_ */
diff --git a/src/media/flickr/grl-flickr.c b/src/media/flickr/grl-flickr.c
index a0d1e7f..ae49fa9 100644
--- a/src/media/flickr/grl-flickr.c
+++ b/src/media/flickr/grl-flickr.c
@@ -343,7 +343,12 @@ update_media (GrlMedia *media, GHashTable *photo)
}
if (date) {
- grl_media_set_date (media, date);
+ GDateTime *date_time;
+ date_time = g_flickr_parse_date (date);
+ if (date_time) {
+ grl_media_set_creation_date (media, date_time);
+ g_date_time_unref (date_time);
+ }
}
if (description && description[0] != '\0') {
@@ -586,7 +591,7 @@ grl_flickr_source_supported_keys (GrlMetadataSource *source)
static GList *keys = NULL;
if (!keys) {
keys = grl_metadata_key_list_new (GRL_METADATA_KEY_AUTHOR,
- GRL_METADATA_KEY_DATE,
+ GRL_METADATA_KEY_CREATION_DATE,
GRL_METADATA_KEY_DESCRIPTION,
GRL_METADATA_KEY_ID,
GRL_METADATA_KEY_THUMBNAIL,
--
1.7.4.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]