Created
August 23, 2018 07:09
-
-
Save geek1706/5fb446c0404e948d479a34d31e6986e3 to your computer and use it in GitHub Desktop.
This file contains 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
import ObjectMapper | |
class CustomDateTransform: TransformType { | |
static let dateFormatter: DateFormatter = { | |
let df = DateFormatter() | |
df.dateFormat = "yyyy-MM-dd" | |
return df | |
}() | |
func transformFromJSON(_ value: Any?) -> Date? { | |
if let dateStr = value as? String { | |
return BirthdayDateTransform.dateFormatter.date(from: dateStr) | |
} | |
return nil | |
} | |
func transformToJSON(_ value: Date?) -> String? { | |
return nil | |
} | |
typealias Object = Date | |
typealias JSON = String | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment