Created
July 13, 2011 15:31
-
-
Save sshrpe/1080532 to your computer and use it in GitHub Desktop.
dateWithRFCString
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NSDateFormatter *rfcDateFormatter = nil; | |
+(NSDate *)dateWithRFCDate:(NSString *)rfcDate; | |
{ | |
if (!rfcDateFormatter) { | |
rfcDateFormatter = [[NSDateFormatter alloc] init]; | |
NSLocale *enUSPOSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]; | |
[rfcDateFormatter setLocale:enUSPOSIXLocale]; | |
[rfcDateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"]; | |
[rfcDateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; | |
} | |
return [rfcDateFormatter dateFromString:rfcDate]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment