[evolution] Bug 793915 - Option to convert UTC time to local time in Reply credits
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 793915 - Option to convert UTC time to local time in Reply credits
- Date: Mon, 12 Mar 2018 13:25:12 +0000 (UTC)
commit ae559e669ce7dcd277d379737e4bbfc75416cd06
Author: Milan Crha <mcrha redhat com>
Date: Mon Mar 12 14:26:31 2018 +0100
Bug 793915 - Option to convert UTC time to local time in Reply credits
data/org.gnome.evolution.mail.gschema.xml.in | 5 +++++
src/mail/em-composer-utils.c | 25 ++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 24f997c..7d4d02d 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -220,6 +220,11 @@
<_summary>Wrap quoted text in replies</_summary>
<_description>If set to “true” quoted text in replies will be wrapped.</_description>
</key>
+ <key name="composer-reply-credits-utc-to-localtime" type="b">
+ <default>false</default>
+ <_summary>Convert UTC time in reply credits to local time</_summary>
+ <_description>Whether the time in reply credits should be converted to local time when it's in UTC in
the message.</_description>
+ </key>
<key name="display-content-disposition-inline" type="b">
<default>true</default>
<_summary>Whether to obey Content-Disposition:inline message header hint</_summary>
diff --git a/src/mail/em-composer-utils.c b/src/mail/em-composer-utils.c
index 7ab04b4..c710512 100644
--- a/src/mail/em-composer-utils.c
+++ b/src/mail/em-composer-utils.c
@@ -54,9 +54,13 @@
#ifdef gmtime_r
#undef gmtime_r
#endif
+#ifdef localtime_r
+#undef localtime_r
+#endif
-/* The gmtime() in Microsoft's C library is MT-safe */
+/* The gmtime() and localtime() in Microsoft's C library are MT-safe */
#define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
+#define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0)
#endif
typedef struct _AsyncContext AsyncContext;
@@ -3325,6 +3329,25 @@ attribution_format (CamelMimeMessage *message)
/* That didn't work either, use current time */
time (&date);
tzone = 0;
+ } else if (tzone == 0) {
+ GSettings *settings;
+
+ settings = e_util_ref_settings ("org.gnome.evolution.mail");
+
+ if (g_settings_get_boolean (settings, "composer-reply-credits-utc-to-localtime")) {
+ struct tm gmtm, lctm;
+ time_t gmtt, lctt;
+
+ gmtime_r (&date, &gmtm);
+ localtime_r (&date, &lctm);
+
+ gmtt = mktime (&gmtm);
+ lctt = mktime (&lctm);
+
+ tzone = (lctt - gmtt) * 100 / 3600;
+ }
+
+ g_clear_object (&settings);
}
/* Convert to UTC */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]