Here is the code snippet:
func mapping(map: Map) { time <- (map["time"], TransformOf<Date, String>(fromJSON: { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "HH:mm:ss" //dateFormatter.timeZone = TimeZone(abbreviation: "EEST") if let argument = $0 { let date = dateFormatter.date(from: argument) return dateFormatter.date(from: argument) } return nil }}
$0 is the line with "22:12:00" . I set the "dating" to see what it returns, and this is zero. I searched for format codes here: http://waracle.net/iphone-nsdateformatter-date-formatting-table/
The code should actually work. What am I doing wrong?
EDIT : added whole function
EDIT2 : I just noticed that it works correctly on iPhone 7 iOS 10.1, but returns zero on iPod 10.1.1 (2016). This is so strange.
date ios swift swift3
monus
source share