[gnome-commander/gcmd-1-4] Support for utf8 encoded dates in document metadata
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/gcmd-1-4] Support for utf8 encoded dates in document metadata
- Date: Wed, 19 Mar 2014 10:51:52 +0000 (UTC)
commit 4bf3ab5edbc8f41f6afa7ba43c0b9ecf34808649
Author: Uwe Scholz <uwescholz src gnome org>
Date: Wed Mar 19 11:09:11 2014 +0100
Support for utf8 encoded dates in document metadata
NEWS | 1 +
doc/C/releases.xml | 3 +++
src/tags/gnome-cmd-tags-poppler.cc | 36 ++++++++++++++++++++++++++----------
3 files changed, 30 insertions(+), 10 deletions(-)
---
diff --git a/NEWS b/NEWS
index dcea8ac..65801b1 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ gnome-commander 1.4.1
Bug fixes:
* Fixed problem bgo#641842 (use poppler-glib instead of poppler internal API)
+ * Support for utf8 encoded creation and modification dates in document metadata
New features:
* New or updated translations:
...
diff --git a/doc/C/releases.xml b/doc/C/releases.xml
index 4bb4491..e4f7a09 100644
--- a/doc/C/releases.xml
+++ b/doc/C/releases.xml
@@ -32,6 +32,9 @@
<listitem>
<para>Fixed problem bgo#641842 (use poppler-glib instead of poppler internal
API)</para>
</listitem>
+ <listitem>
+ <para>Support for utf8 encoded creation and modification dates in document
metadata</para>
+ </listitem>
</itemizedlist>
</para>
<para>New features:</para>
diff --git a/src/tags/gnome-cmd-tags-poppler.cc b/src/tags/gnome-cmd-tags-poppler.cc
index ccfa5bf..b6544dd 100644
--- a/src/tags/gnome-cmd-tags-poppler.cc
+++ b/src/tags/gnome-cmd-tags-poppler.cc
@@ -36,15 +36,25 @@ using namespace std;
#ifdef HAVE_PDF
-static void add_date(GnomeCmdFileMetadata &metadata, GnomeCmdTag tag, time_t date)
+gchar * pgd_format_date (time_t utime)
{
- gchar buf[32];
- struct tm lt;
-
- localtime_r(&date, <);
- strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", <);
-
- metadata.add(tag, buf);
+ time_t time = (time_t) utime;
+ char s[256];
+ const char *fmt_hack = "%c";
+ size_t len;
+#ifdef HAVE_LOCALTIME_R
+ struct tm t;
+ if (time == 0 || !localtime_r (&time, &t)) return NULL;
+ len = strftime (s, sizeof (s), fmt_hack, &t);
+#else
+ struct tm *t;
+ if (time == 0 || !(t = localtime (&time)) ) return NULL;
+ len = strftime (s, sizeof (s), fmt_hack, t);
+#endif
+
+ if (len == 0 || s[0] == '\0') return NULL;
+
+ return g_locale_to_utf8 (s, -1, NULL, NULL, NULL);
}
inline guint enum_bit_to_01(int enum_value, int enum_bit)
@@ -224,6 +234,7 @@ void gcmd_tags_poppler_load_metadata(GnomeCmdFile *f)
f->metadata->mark_as_accessed(TAG_DOC);
gchar *title, *author, *subject, *keywords, *creator, *producer;
+ gchar *str;
GTime creation_date, mod_date;
PopplerPermissions permissions;
guint format_major, format_minor;
@@ -279,8 +290,13 @@ void gcmd_tags_poppler_load_metadata(GnomeCmdFile *f)
f->metadata->add(TAG_DOC_GENERATOR, producer);
g_free(producer);
- add_date(*f->metadata, TAG_DOC_DATECREATED, creation_date);
- add_date(*f->metadata, TAG_DOC_DATEMODIFIED, mod_date);
+ str = pgd_format_date (creation_date);
+ f->metadata->add(TAG_DOC_DATECREATED, str);
+
+ str = pgd_format_date (mod_date);
+ f->metadata->add(TAG_DOC_DATEMODIFIED, str);
+
+ g_free (str);
if (poppler_document_get_n_pages(document) > 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]