-
-
Save eMdOS/ec207ac903792dd89102376c536f4adc to your computer and use it in GitHub Desktop.
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
// Swift 3 | |
extension DateFormatter { | |
public static var iso8601: DateFormatter { | |
return DateFormatter.iso8601DateFormatter | |
} | |
private static let iso8601DateFormatter: DateFormatter = { | |
let formatter = DateFormatter() | |
formatter.locale = Locale(identifier: "en_US_POSIX") | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" | |
return formatter | |
}() | |
} |
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
// Swift 2.2 | |
extension NSDateFormatter { | |
public static var iso8601: NSDateFormatter { | |
return NSDateFormatter.iso8601DateFormatter | |
} | |
private static let iso8601DateFormatter: NSDateFormatter = { | |
let formatter = NSDateFormatter() | |
formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" | |
return formatter | |
}() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment