I have this code in my project:
class ShippingDay: EVObject, Mappable {
var periods: [String]?
var date: Date?
required init(map: Mapper) throws {
self.periods = map.optionalFrom("periods")
if let dateStr:String = map.optionalFrom("date") {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy/MM/dd"
//formatter.locale = Locale(identifier: "en_US_POSIX")
//formatter.calendar = Calendar(identifier: .gregorian)
self.date = formatter.date(from: dateStr)
}
}
here is the theoretical proof in playground that this should work:
But this is what I get:
Can some enlightened soul please explain me what the hell is happening here?? Why my self.date is always nil? I tried without the comments and the result is the same... nil
UPDATED evidence: