Skip to content

Commit

Permalink
Set NSDateFormatter Locale en_US_POSIX
Browse files Browse the repository at this point in the history
  • Loading branch information
ObjColumnist committed Aug 6, 2014
1 parent bf3d2ec commit bc7f205
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions Extensions/XEP-0009/XMPPIQ+JabberRPCResonse.m
Expand Up @@ -236,12 +236,10 @@ -(NSDictionary *)parseMember:(NSXMLElement *)memberElement {

- (NSDate *)parseDateString: (NSString *)dateString withFormat: (NSString *)format {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSDate *result = nil;

[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter setDateFormat: format];

result = [dateFormatter dateFromString: dateString];

NSDate *result = [dateFormatter dateFromString: dateString];

return result;
}
Expand Down
1 change: 1 addition & 0 deletions Extensions/XEP-0082/NSDate+XMPPDateTimeProfiles.m
Expand Up @@ -67,6 +67,7 @@ - (NSString *)xmppStringWithDateFormat:(NSString *)dateFormat
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter setDateFormat:dateFormat];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];

Expand Down
6 changes: 3 additions & 3 deletions Extensions/XEP-0082/XMPPDateTimeProfiles.m
Expand Up @@ -47,7 +47,7 @@ + (NSDate *)parseDate:(NSString *)dateStr

NSDateFormatter *df = [self threadDateFormatter];
[df setFormatterBehavior:NSDateFormatterBehavior10_4]; // Use unicode patterns (as opposed to 10_3)
[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]]; //Bypass NSDateFormatter locale bug
[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[df setDateFormat:@"yyyy-MM-dd"];

NSDate *result = [df dateFromString:dateStr];
Expand Down Expand Up @@ -87,7 +87,7 @@ + (NSDate *)parseTime:(NSString *)timeStr

NSDateFormatter *df = [self threadDateFormatter];
[df setFormatterBehavior:NSDateFormatterBehavior10_4]; // Use unicode patterns (as opposed to 10_3)
[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]]; //Bypass NSDateFormatter locale bug
[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[df setDateFormat:@"yyyy-MM-dd"];

NSString *today = [df stringFromDate:[NSDate date]];
Expand Down Expand Up @@ -191,7 +191,7 @@ + (NSDate *)parseDateTime:(NSString *)dateTimeStr withMandatoryTimeZone:(BOOL)ma

NSDateFormatter *df = [self threadDateFormatter];
[df setFormatterBehavior:NSDateFormatterBehavior10_4]; // Use unicode patterns (as opposed to 10_3)
[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]]; //Bypass NSDateFormatter locale bug
[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];

NSDate *result = nil;
Expand Down
1 change: 1 addition & 0 deletions Extensions/XEP-0202/XMPPTime.m
Expand Up @@ -453,6 +453,7 @@ + (NSXMLElement *)timeElementFromDate:(NSDate *)date

NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setFormatterBehavior:NSDateFormatterBehavior10_4]; // Use unicode patterns (as opposed to 10_3)
[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
[df setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];

Expand Down
1 change: 1 addition & 0 deletions Extensions/XEP-0203/NSXMLElement+XEP_0203.m
Expand Up @@ -69,6 +69,7 @@ - (NSDate *)delayedDeliveryDate

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter setDateFormat:@"yyyyMMdd'T'HH:mm:ss"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];

Expand Down

0 comments on commit bc7f205

Please sign in to comment.