완료 방송 상대 시간 표시
최근 종료 방송 카드에 UTC 기준 상대 시간 문자열을 표시한다.
This commit is contained in:
@@ -67,55 +67,3 @@ extension GetCommunityPostListResponse {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 내부: 다양한 포맷 파서를 시도
|
||||
private enum DateParser {
|
||||
static func parse(_ text: String) -> Date? {
|
||||
for parser in parsers {
|
||||
if let d = parser(text) { return d }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 시도 순서: ISO8601(소수초 포함) → ISO8601 → RFC3339 유사 → 공백 구분 기본
|
||||
private static let parsers: [(String) -> Date?] = [
|
||||
{ ISO8601.fractional.date(from: $0) },
|
||||
{ ISO8601.basic.date(from: $0) },
|
||||
{ DF.rfc3339.date(from: $0) },
|
||||
{ DF.basic.date(from: $0) }
|
||||
]
|
||||
|
||||
private enum ISO8601 {
|
||||
static let fractional: ISO8601DateFormatter = {
|
||||
let f = ISO8601DateFormatter()
|
||||
f.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
f.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
return f
|
||||
}()
|
||||
|
||||
static let basic: ISO8601DateFormatter = {
|
||||
let f = ISO8601DateFormatter()
|
||||
f.formatOptions = [.withInternetDateTime]
|
||||
f.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
return f
|
||||
}()
|
||||
}
|
||||
|
||||
private enum DF {
|
||||
static let rfc3339: DateFormatter = {
|
||||
let f = DateFormatter()
|
||||
f.locale = Locale(identifier: "en_US_POSIX")
|
||||
f.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
f.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
|
||||
return f
|
||||
}()
|
||||
|
||||
static let basic: DateFormatter = {
|
||||
let f = DateFormatter()
|
||||
f.locale = Locale(identifier: "en_US_POSIX")
|
||||
f.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
f.dateFormat = "yyyy-MM-dd HH:mm:ss"
|
||||
return f
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user