Nathan de Vries
Committed by Ben Copsey

Use the "en_US_POSIX" locale to ensure 12-hour time settings don't affect the be…

…havior of NSDateFormatter on the iPhone.

Signed-off-by: Ben Copsey <ben@allseeing-i.com>
@@ -24,6 +24,7 @@ static NSDateFormatter *dateFormatter = nil; @@ -24,6 +24,7 @@ static NSDateFormatter *dateFormatter = nil;
24 + (void)initialize 24 + (void)initialize
25 { 25 {
26 dateFormatter = [[NSDateFormatter alloc] init]; 26 dateFormatter = [[NSDateFormatter alloc] init];
  27 + [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
27 [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; 28 [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
28 [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'.000Z'"]; 29 [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'.000Z'"];
29 } 30 }
@@ -87,7 +87,7 @@ static NSString *sharedSecretAccessKey = nil; @@ -87,7 +87,7 @@ static NSString *sharedSecretAccessKey = nil;
87 { 87 {
88 NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; 88 NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
89 // Prevent problems with dates generated by other locales (tip from: http://rel.me/t/date/) 89 // Prevent problems with dates generated by other locales (tip from: http://rel.me/t/date/)
90 - [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]]; 90 + [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
91 [dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss Z"]; 91 [dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss Z"];
92 [self setDateString:[dateFormatter stringFromDate:date]]; 92 [self setDateString:[dateFormatter stringFromDate:date]];
93 } 93 }