Use `ISO8601DateFormatter`

This commit is contained in:
Quentin Jin 2019-03-18 21:21:09 +08:00
parent 28df34d300
commit 3cbf95efbf
1 changed files with 4 additions and 3 deletions

View File

@ -22,12 +22,13 @@ extension Timeline: CustomStringConvertible {
/// A textual representation of this timeline. /// A textual representation of this timeline.
public var description: String { public var description: String {
let f = DateFormatter() enum Cache {
f.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS" static let fmt = ISO8601DateFormatter()
}
let desc = { (d: Date?) -> String in let desc = { (d: Date?) -> String in
guard let d = d else { return "nil" } guard let d = d else { return "nil" }
return f.string(from: d) return Cache.fmt.string(from: d)
} }
return "Timeline: { " + return "Timeline: { " +