Last active
October 25, 2017 02:50
-
-
Save d-date/3ff4b2e2f24c84551ab9d88fc7b62907 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// This extension is only available on iOS prior to 10.0. | |
// If you want to use on iOS 10.0 and later, please use ISO8601DateFormatter | |
extension DateFormatter { | |
@available(*, obsoleted: 10.0, message: "use ISO8601DateFormatter") | |
static let iso8601: DateFormatter = { | |
let formatter = DateFormatter() | |
formatter.calendar = Calendar(identifier: .iso8601) | |
formatter.locale = Locale(identifier: "en_US_POSIX") | |
formatter.timeZone = TimeZone(secondsFromGMT: 0) | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX" | |
return formatter | |
}() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment