Skip to content

Instantly share code, notes, and snippets.

@sshrpe
Created July 13, 2011 15:31
Show Gist options
  • Save sshrpe/1080532 to your computer and use it in GitHub Desktop.
Save sshrpe/1080532 to your computer and use it in GitHub Desktop.
dateWithRFCString
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