Skip to content

Instantly share code, notes, and snippets.

@perlmunger
Last active April 25, 2017 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perlmunger/ddafb785a11a6bba9f43cd3324d98c72 to your computer and use it in GitHub Desktop.
Save perlmunger/ddafb785a11a6bba9f43cd3324d98c72 to your computer and use it in GitHub Desktop.
// ISO 8601 Extension for Swift to send dates to Ruby on Rails
extension Date {
init(dateString:String) {
self = Date.iso8601Formatter.date(from: dateString)!
}
static let iso8601Formatter: ISO8601DateFormatter = {
let formatter = ISO8601DateFormatter()
formatter.formatOptions = [.withFullDate,
.withTime,
.withDashSeparatorInDate,
.withColonSeparatorInTime]
return formatter
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment