diff --git a/ChangeLog b/ChangeLog index 9aa05fb7c..92a2f538b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-04-25 Wolfgang Sourdeau + * SoObjects/SOGo/NSCalendarDate+SOGo.m ([NSCalendarDate + rfc822DateString]): new method that returns a string conform to + rfc 822 and suitable for email headers. + * SoObjects/Mailer/SOGoDraftObject.m: invoke the new "rfc822DateString" category method on the date we put in the header. diff --git a/SoObjects/SOGo/NSCalendarDate+SOGo.h b/SoObjects/SOGo/NSCalendarDate+SOGo.h index 84c2c66a7..ca6d710d3 100644 --- a/SoObjects/SOGo/NSCalendarDate+SOGo.h +++ b/SoObjects/SOGo/NSCalendarDate+SOGo.h @@ -39,6 +39,8 @@ - (NSCalendarDate *) sundayOfWeek; - (NSString *) shortDateString; +- (NSString *) rfc822DateString; + @end #endif /* NSCALENDARDATE_SCHEDULER_H */ diff --git a/SoObjects/SOGo/NSCalendarDate+SOGo.m b/SoObjects/SOGo/NSCalendarDate+SOGo.m index a6160cadc..c3cd24921 100644 --- a/SoObjects/SOGo/NSCalendarDate+SOGo.m +++ b/SoObjects/SOGo/NSCalendarDate+SOGo.m @@ -19,10 +19,18 @@ 02111-1307, USA. */ +#import +#import #import #import "NSCalendarDate+SOGo.h" +static NSString *rfc822Days[] = {@"Sun", @"Mon", @"Tue", @"Wed", @"Thu", + @"Fri", @"Sat"}; +static NSString *rfc822Months[] = {@"", @"Jan", @"Feb", @"Mar", @"Apr", + @"May", @"Jun", @"Jul", @"Aug" , @"Sep", + @"Oct", @"Nov", @"Dec"}; + @implementation NSCalendarDate (SOGoExtensions) + (id) dateFromShortDateString: (NSString *) dateString @@ -110,4 +118,22 @@ return str; } +- (NSString *) rfc822DateString +{ + int timeZoneShift, tzSeconds; + + tzSeconds = [[self timeZone] secondsFromGMT]; + timeZoneShift = (tzSeconds / 3600); + tzSeconds -= timeZoneShift * 3600; + timeZoneShift *= 100; + timeZoneShift += tzSeconds / 60; + + return + [NSString stringWithFormat: @"%@, %.2d %@ %d %.2d:%.2d:%.2d %.4d", + rfc822Days[[self dayOfWeek]], [self dayOfMonth], + rfc822Months[[self monthOfYear]], [self yearOfCommonEra], + [self hourOfDay], [self minuteOfHour], [self secondOfMinute], + timeZoneShift]; +} + @end