[evolution] I#752 - Incorrect time shown in Reply credits for Australia/Adelaide



commit eddfa12b6f8d1b6565a2cae248fb95f009000171
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jan 14 14:37:57 2020 +0100

    I#752 - Incorrect time shown in Reply credits for Australia/Adelaide
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/752

 src/em-format/e-mail-formatter-quote-headers.c | 15 ++++++---------
 src/mail/em-composer-utils.c                   | 13 +++++--------
 2 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/src/em-format/e-mail-formatter-quote-headers.c b/src/em-format/e-mail-formatter-quote-headers.c
index 68e3cc779b..e0f349457e 100644
--- a/src/em-format/e-mail-formatter-quote-headers.c
+++ b/src/em-format/e-mail-formatter-quote-headers.c
@@ -219,18 +219,15 @@ emfqe_format_header (EMailFormatter *formatter,
 
                        date = camel_header_decode_date (txt, &offset);
                        if (date > 0 && !offset) {
-                               struct tm gmtm, lctm;
-                               time_t gmtt, lctt;
+                               struct tm local;
+                               gint tzone = 0;
 
-                               gmtime_r (&date, &gmtm);
-                               localtime_r (&date, &lctm);
+                               e_localtime_with_offset (date, &local, &offset);
 
-                               gmtt = mktime (&gmtm);
-                               lctt = mktime (&lctm);
+                               tzone = offset / 3600;
+                               tzone = (tzone * 100) + ((offset / 60) % 60);
 
-                               offset = (lctt - gmtt) * 100 / 3600;
-
-                               value = camel_header_format_date (date, offset);
+                               value = camel_header_format_date (date, tzone);
 
                                if (value && *value)
                                        txt = value;
diff --git a/src/mail/em-composer-utils.c b/src/mail/em-composer-utils.c
index fb4b85b570..f94c711d86 100644
--- a/src/mail/em-composer-utils.c
+++ b/src/mail/em-composer-utils.c
@@ -3495,16 +3495,13 @@ em_composer_utils_get_reply_credits (ESource *identity_source,
                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;
+                       struct tm local;
+                       gint offset = 0;
 
-                       gmtime_r (&date, &gmtm);
-                       localtime_r (&date, &lctm);
+                       e_localtime_with_offset (date, &local, &offset);
 
-                       gmtt = mktime (&gmtm);
-                       lctt = mktime (&lctm);
-
-                       tzone = (lctt - gmtt) * 100 / 3600;
+                       tzone = offset / 3600;
+                       tzone = (tzone * 100) + ((offset / 60) % 60);
                }
 
                g_clear_object (&settings);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]