summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2017-05-07 15:21:39 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2017-05-07 15:21:39 +0200
commit29381f9e70d122ea4d89d71ea97f42253c528211 (patch)
tree14c947844ea4402658bdfdf7e7b4810ed781fd81
parentdb3d992febbe703931840e9bdad95c43081694a5 (diff)
downloadcataract-29381f9e70d122ea4d89d71ea97f42253c528211.tar.xz
jpeg-utils: Allow custom datetime format
The default locale datetime format string may not suit everyone, this adds possibility to specify custom format. The format string should be syntactically conforming to strftime(3).
-rw-r--r--sample/src/setup.xml6
-rw-r--r--src/generators.c2
-rw-r--r--src/jpeg-utils.cpp4
-rw-r--r--src/jpeg-utils.h1
-rw-r--r--src/setup.c2
-rw-r--r--src/setup.h1
6 files changed, 14 insertions, 2 deletions
diff --git a/sample/src/setup.xml b/sample/src/setup.xml
index 54bfb5b..f36b01b 100644
--- a/sample/src/setup.xml
+++ b/sample/src/setup.xml
@@ -72,6 +72,12 @@ And the second line.</add_copyright>
<!-- ASCII encoding preferred. -->
<artist_name>John Doe</artist_name>
+ <!-- Specify datetime format according to strftime(3). Leave unspecified -->
+ <!-- for default format string according to current locale. -->
+ <!-- Note that in travel photography in general it makes sense to always -->
+ <!-- show local time, omitting timezone. -->
+<!-- <datetime format="%c" /> -->
+
<!-- favicon support, the "type" attribute is optional, -->
<!-- please alter it to the right icon MIME type -->
<!-- http://www.w3.org/2005/10/howto-favicon -->
diff --git a/src/generators.c b/src/generators.c
index ed525cf..5ab5765 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -320,6 +320,8 @@ metadata_apply_overrides (ExifData *exif_data,
exif_data->thumbnail_crop_hint = get_prop_int (items, item, PROP_THUMB_CROP_HINT, CROP_HINT_UNDEFINED);
exif_data->shave_amount = get_prop_int (items, item, PROP_SHAVE_AMOUNT, 0);
+
+ exif_data->datetime_format = setup->datetime_format;
}
static char *
diff --git a/src/jpeg-utils.cpp b/src/jpeg-utils.cpp
index e9e1e65..61aeebd 100644
--- a/src/jpeg-utils.cpp
+++ b/src/jpeg-utils.cpp
@@ -289,7 +289,7 @@ get_exif_data_fixed (ExifData *exif, const gchar *key)
if (exif->override_datetime != (time_t) -1) {
tt = (struct tm *) g_malloc0 (sizeof (struct tm));
localtime_r (&exif->override_datetime, tt);
- if (strftime (&conv[0], sizeof (conv), "%c", tt))
+ if (strftime (&conv[0], sizeof (conv), exif->datetime_format ? exif->datetime_format : "%c", tt))
res = g_strdup (&conv[0]);
}
@@ -297,7 +297,7 @@ get_exif_data_fixed (ExifData *exif, const gchar *key)
tt = parse_exif_date (val);
if (tt) {
shift_time (tt, exif->timezone_shift);
- if (strftime (&conv[0], sizeof (conv), "%c", tt))
+ if (strftime (&conv[0], sizeof (conv), exif->datetime_format ? exif->datetime_format : "%c", tt))
res = g_strdup (&conv[0]);
}
}
diff --git a/src/jpeg-utils.h b/src/jpeg-utils.h
index b4ead79..767320a 100644
--- a/src/jpeg-utils.h
+++ b/src/jpeg-utils.h
@@ -58,6 +58,7 @@ typedef struct {
double override_focal_length;
gchar *override_artist_name;
gchar *external_exif_data;
+ const gchar *datetime_format;
TCropStyle thumbnail_crop_style;
TCropHint thumbnail_crop_hint;
int shave_amount;
diff --git a/src/setup.c b/src/setup.c
index cf23044..85c7326 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -113,6 +113,7 @@ parse_setup_xml (const gchar *filename)
setup->site_title = xml_file_get_node_attribute (xml, "/gallery_setup/meta/site", "title");
setup->add_copyright = xml_file_get_node_value (xml, "/gallery_setup/meta/add_copyright/text()");
setup->meta_artist_name = xml_file_get_node_value (xml, "/gallery_setup/meta/artist_name/text()");
+ setup->datetime_format = xml_file_get_node_attribute (xml, "/gallery_setup/meta/datetime", "format");
setup->favicon_file = xml_file_get_node_value (xml, "/gallery_setup/meta/favicon/text()");
setup->favicon_type = xml_file_get_node_attribute (xml, "/gallery_setup/meta/favicon", "type");
@@ -685,6 +686,7 @@ free_setup_data (TGallerySetup *setup)
g_free (setup->site_title);
g_free (setup->add_copyright);
g_free (setup->meta_artist_name);
+ g_free (setup->datetime_format);
g_free (setup->favicon_file);
g_free (setup->favicon_type);
g_free (setup->feed_filename);
diff --git a/src/setup.h b/src/setup.h
index 730c035..009566a 100644
--- a/src/setup.h
+++ b/src/setup.h
@@ -74,6 +74,7 @@ typedef struct {
gchar *site_title;
gchar *add_copyright;
gchar *meta_artist_name;
+ gchar *datetime_format;
gchar *favicon_file;
gchar *favicon_type;