Merge pull request #2077 from spotby/swift-java-date

adding support for java dates
This commit is contained in:
wing328 2016-02-11 09:03:19 +08:00
commit f50174e950

View File

@ -109,13 +109,19 @@ class Decoders {
}
// Decoder for NSDate
Decoders.addDecoder(clazz: NSDate.self) { (source: AnyObject) -> NSDate in
let sourceString = source as! String
if let sourceString = source as? String {
for formatter in formatters {
if let date = formatter.dateFromString(sourceString) {
return date
}
}
fatalError("formatter failed to parse \(sourceString)")
}
if let sourceInt = source as? Int {
// treat as a java date
return NSDate(timeIntervalSince1970: Double(sourceInt / 1000) )
}
fatalError("formatter failed to parse \(source)")
} {{#models}}{{#model}}
// Decoder for [{{{classname}}}]