[geary] Fix composed email Date: header: Closes bug #714376



commit f38c8c70cab0c582307f77259ef39ad8fce58fd4
Author: Jim Nelson <jim yorba org>
Date:   Mon May 12 14:44:34 2014 -0700

    Fix composed email Date: header: Closes bug #714376
    
    GMime documentation suggests its date conversion methods take a
    time zone offset in hours, but it appears the number must be base-100
    to get the right results (i.e. -7 becomes "-0700").

 src/engine/rfc822/rfc822-message-data.vala |    6 +++++-
 src/engine/rfc822/rfc822-message.vala      |    3 +--
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-message-data.vala b/src/engine/rfc822/rfc822-message-data.vala
index 8c9cdb4..975fc7e 100644
--- a/src/engine/rfc822/rfc822-message-data.vala
+++ b/src/engine/rfc822/rfc822-message-data.vala
@@ -164,7 +164,11 @@ public class Geary.RFC822.Date : Geary.RFC822.MessageData, Geary.MessageData.Abs
      * Returns the { link Date} in ISO-8601 format.
      */
     public virtual string serialize() {
-        return GMime.utils_header_format_date(as_time_t, 0);
+        // Although GMime documents its conversion methods as requiring the tz offset in hours,
+        // it appears the number is handed directly to the string (i.e. an offset of -7 becomes
+        // "-0007", whereas we want "-0700").
+        return GMime.utils_header_format_date(as_time_t,
+            (int) (value.get_utc_offset() / TimeSpan.HOUR) * 100);
     }
     
     public virtual uint hash() {
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index aa32c6b..f38b694 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -96,8 +96,7 @@ public class Geary.RFC822.Message : BaseObject {
         date = new RFC822.Date.from_date_time(email.date);
         
         message.set_sender(sender.to_rfc822_string());
-        message.set_date((time_t) email.date.to_unix(),
-            (int) (email.date.get_utc_offset() / TimeSpan.HOUR));
+        message.set_date_as_string(date.serialize());
         if (message_id != null)
             message.set_message_id(message_id);
         


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