Use ISO8601DateFormatter.

Resolve #613

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-27 14:54:07 -04:00
parent 705563ced9
commit e79e6283ac
No known key found for this signature in database

View file

@ -47,12 +47,8 @@ enum AppInfoFormatter {
/// - Parameter serverDate: String containing a date in ISO-8601 format. /// - Parameter serverDate: String containing a date in ISO-8601 format.
/// - Returns: Simple date format. /// - Returns: Simple date format.
private static func humanReadableDate(_ serverDate: String) -> String { private static func humanReadableDate(_ serverDate: String) -> String {
let serverDateFormatter = DateFormatter() let humanDateFormatter = ISO8601DateFormatter()
serverDateFormatter.locale = Locale(identifier: "en_US_POSIX") humanDateFormatter.formatOptions = [.withFullDate]
serverDateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" return ISO8601DateFormatter().date(from: serverDate).map(humanDateFormatter.string(from:)) ?? ""
let humanDateFormatter = DateFormatter()
humanDateFormatter.dateFormat = "yyyy-MM-dd"
return serverDateFormatter.date(from: serverDate).flatMap(humanDateFormatter.string(from:)) ?? ""
} }
} }