summaryrefslogtreecommitdiff
path: root/src/items.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/items.c')
-rw-r--r--src/items.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/items.c b/src/items.c
index a0c2534..6ac7e56 100644
--- a/src/items.c
+++ b/src/items.c
@@ -30,6 +30,30 @@
#include "atom-writer.h"
+
+static int
+parse_timezone_string (const gchar *str)
+{
+ int hour = 0;
+ int min = 0;
+ float f;
+ char *endptr = NULL;
+
+ /* Expecting +-hh:mm format */
+ if (sscanf (str, "%d:%d", &hour, &min) != 2) {
+ /* Try simple float conversion instead */
+ f = strtof (str, &endptr);
+ if (endptr == NULL || *endptr != '\0') {
+ log_error ("Invalid timezone string \"%s\", ignoring.\n", str);
+ return 0;
+ }
+ return (int)(f * 60);
+ }
+
+ return hour * 60 + min;
+}
+
+
/*
* parse_album_xml: XML parser for gallery index.xml files
*/
@@ -92,6 +116,13 @@ parse_album_xml (const gchar *filename, TPathInfo *path_info)
index->meta_description = xml_file_get_node_value (xml, "/gallery/general/meta/description/text()");
index->meta_keywords = xml_file_get_node_value (xml, "/gallery/general/meta/keywords/text()");
+ s = xml_file_get_node_attribute (xml, "/gallery/general/metadata/timezone", "shift");
+ if (s != NULL) {
+ index->metadata_tz_shift = parse_timezone_string (s2);
+ g_free (s2);
+ }
+
+
index->nofullsize = xml_file_get_node_present (xml, "/gallery/general/nofullsize");
index->fullsize = xml_file_get_node_present (xml, "/gallery/general/fullsize");
@@ -219,6 +250,14 @@ parse_album_xml (const gchar *filename, TPathInfo *path_info)
item->metadata_external_exif = xml_file_get_node_attribute (xml, s, "src");
g_free (s);
+ s = g_strdup_printf ("/gallery/items/*[%d]/metadata/timezone", i + 1);
+ s2 = xml_file_get_node_attribute (xml, s, "shift");
+ g_free (s);
+ if (s2 != NULL) {
+ item->metadata_tz_shift = parse_timezone_string (s2);
+ g_free (s2);
+ }
+
if (item->path || item->preview) {
g_ptr_array_add (index->items, item);
} else {