[geary] Some date-related fixes



commit 0eb0a2d6e60a683521d577770a022caff354ac47
Author: Jim Nelson <jim yorba org>
Date:   Mon May 12 15:44:22 2014 -0700

    Some date-related fixes

 bindings/vapi/gmime-2.6.vapi                    |    2 +-
 bindings/vapi/gmime-2.6/gmime-2.6.metadata      |    2 +-
 src/engine/imap/message/imap-internal-date.vala |    4 +---
 src/engine/rfc822/rfc822-message-data.vala      |   19 ++++++++++++++-----
 4 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/bindings/vapi/gmime-2.6.vapi b/bindings/vapi/gmime-2.6.vapi
index c7769fc..8d8c104 100644
--- a/bindings/vapi/gmime-2.6.vapi
+++ b/bindings/vapi/gmime-2.6.vapi
@@ -1352,7 +1352,7 @@ namespace GMime {
        [CCode (cheader_filename = "gmime/gmime.h", cname = "g_mime_utils_generate_message_id")]
        public static string utils_generate_message_id (string fqdn);
        [CCode (cheader_filename = "gmime/gmime.h", cname = "g_mime_utils_header_decode_date")]
-       public static time_t utils_header_decode_date (string str, out unowned int? tz_offset);
+       public static time_t utils_header_decode_date (string str, out int tz_offset);
        [CCode (cheader_filename = "gmime/gmime.h", cname = "g_mime_utils_header_decode_phrase")]
        public static string utils_header_decode_phrase (string phrase);
        [CCode (cheader_filename = "gmime/gmime.h", cname = "g_mime_utils_header_decode_text")]
diff --git a/bindings/vapi/gmime-2.6/gmime-2.6.metadata b/bindings/vapi/gmime-2.6/gmime-2.6.metadata
index 9ee2701..903a535 100644
--- a/bindings/vapi/gmime-2.6/gmime-2.6.metadata
+++ b/bindings/vapi/gmime-2.6/gmime-2.6.metadata
@@ -29,7 +29,7 @@ g_mime_utils_decode_8bit transfer_ownership="1"
 g_mime_utils_decode_message_id transfer_ownership="1"
 g_mime_utils_generate_message_id transfer_ownership="1"
 g_mime_utils_header_decode_date type_name="time_t"
-g_mime_utils_header_decode_date.tz_offset is_out="1" nullable="1"
+g_mime_utils_header_decode_date.tz_offset is_out="1"
 g_mime_utils_header_decode_phrase transfer_ownership="1"
 g_mime_utils_header_decode_text transfer_ownership="1"
 g_mime_utils_header_encode_phrase transfer_ownership="1"
diff --git a/src/engine/imap/message/imap-internal-date.vala b/src/engine/imap/message/imap-internal-date.vala
index 157fb76..6fd9ff1 100644
--- a/src/engine/imap/message/imap-internal-date.vala
+++ b/src/engine/imap/message/imap-internal-date.vala
@@ -84,9 +84,7 @@ public class Geary.Imap.InternalDate : Geary.MessageData.AbstractMessageData, Ge
         
         // TODO: verify timezone
         
-        // if no timezone listed, ISO 8601 says to use local time, but that doesn't make sense with
-        // most IMAP servers which have no out-of-band mechanism to know the client's timezone, so
-        // assuming UTC
+        // if no timezone listed, ISO 8601 says to use local time
         TimeZone timezone = (tz[0] != '\0') ? new TimeZone((string) tz) : new TimeZone.local();
         
         // assemble into DateTime, which validates the time as well (this is why we want to keep
diff --git a/src/engine/rfc822/rfc822-message-data.vala b/src/engine/rfc822/rfc822-message-data.vala
index 975fc7e..84d7539 100644
--- a/src/engine/rfc822/rfc822-message-data.vala
+++ b/src/engine/rfc822/rfc822-message-data.vala
@@ -156,14 +156,10 @@ public class Geary.RFC822.Date : Geary.RFC822.MessageData, Geary.MessageData.Abs
         as_time_t = Time.datetime_to_time_t(datetime);
     }
     
-    public virtual bool equal_to(Geary.RFC822.Date other) {
-        return (this != other) ? value.equal(other.value) : true;
-    }
-    
     /**
      * Returns the { link Date} in ISO-8601 format.
      */
-    public virtual string serialize() {
+    public string to_iso_8601() {
         // 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").
@@ -171,6 +167,19 @@ public class Geary.RFC822.Date : Geary.RFC822.MessageData, Geary.MessageData.Abs
             (int) (value.get_utc_offset() / TimeSpan.HOUR) * 100);
     }
     
+    /**
+     * Returns { link Date} for transmission.
+     *
+     * @see to_iso_8601
+     */
+    public virtual string serialize() {
+        return to_iso_8601();
+    }
+    
+    public virtual bool equal_to(Geary.RFC822.Date other) {
+        return (this != other) ? value.equal(other.value) : true;
+    }
+    
     public virtual uint hash() {
         return value.hash();
     }


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