Some date-related fixes

This commit is contained in:
Jim Nelson 2014-05-12 15:44:22 -07:00
parent f38c8c70ca
commit 0eb0a2d6e6
4 changed files with 17 additions and 10 deletions

View file

@ -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")]

View file

@ -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"

View file

@ -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

View file

@ -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();
}