From ae559e669ce7dcd277d379737e4bbfc75416cd06 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 12 Mar 2018 14:26:31 +0100 Subject: [PATCH] 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 deletion(-) diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in index 24f997c684..7d4d02d4c5 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 <_description>If set to “true” quoted text in replies will be wrapped. + + false + <_summary>Convert UTC time in reply credits to local time + <_description>Whether the time in reply credits should be converted to local time when it's in UTC in the message. + true <_summary>Whether to obey Content-Disposition:inline message header hint diff --git a/src/mail/em-composer-utils.c b/src/mail/em-composer-utils.c index 7ab04b44d3..c710512275 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 */ -- 2.11.4.GIT