From 3cbf95efbf2c838aebaa9b260c630f5c47326d2a Mon Sep 17 00:00:00 2001 From: Quentin Jin Date: Mon, 18 Mar 2019 21:21:09 +0800 Subject: [PATCH] Use `ISO8601DateFormatter` --- Sources/Schedule/Timeline.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/Schedule/Timeline.swift b/Sources/Schedule/Timeline.swift index 9cce011..35994aa 100644 --- a/Sources/Schedule/Timeline.swift +++ b/Sources/Schedule/Timeline.swift @@ -22,12 +22,13 @@ extension Timeline: CustomStringConvertible { /// A textual representation of this timeline. public var description: String { - let f = DateFormatter() - f.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS" + enum Cache { + static let fmt = ISO8601DateFormatter() + } let desc = { (d: Date?) -> String in guard let d = d else { return "nil" } - return f.string(from: d) + return Cache.fmt.string(from: d) } return "Timeline: { " +