Created
May 19, 2015 14:16
-
-
Save eddieespinal/f6ce7c0349ebd165f5f6 to your computer and use it in GitHub Desktop.
// These functions are not thread-safe, nor are the NSDateFormatter instances they return. // Make sure that this function and the formatter are called on only one thread at a time.
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
#pragma mark - DATE CONVERSION: | |
// These functions are not thread-safe, nor are the NSDateFormatter instances they return. | |
// Make sure that this function and the formatter are called on only one thread at a time. | |
static NSDateFormatter* getISO8601Formatter() { | |
static NSDateFormatter* sFormatter; | |
if (!sFormatter) { | |
// Thanks to DenNukem's answer in http://stackoverflow.com/questions/399527/ | |
sFormatter = [[NSDateFormatter alloc] init]; | |
sFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; | |
sFormatter.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; | |
sFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; | |
} | |
return sFormatter; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment