feat(main): 홈 대화 탭을 추가한다
This commit is contained in:
@@ -47,6 +47,44 @@ enum DateParser {
|
||||
|
||||
return I18n.Time.daysAgo(max(1, Int(interval / 86_400)))
|
||||
}
|
||||
|
||||
static func chatListDateText(fromUTC text: String, fallback: String, now: Date = Date()) -> String {
|
||||
guard let date = parse(text) else {
|
||||
return fallback
|
||||
}
|
||||
|
||||
let interval = max(0, now.timeIntervalSince(date))
|
||||
if interval < 60 {
|
||||
return I18n.Time.justNow
|
||||
}
|
||||
|
||||
if interval < 3600 {
|
||||
return I18n.Time.minutesAgo(max(1, Int(interval / 60)))
|
||||
}
|
||||
|
||||
if interval < 86_400 {
|
||||
return I18n.Time.hoursAgo(max(1, Int(interval / 3600)))
|
||||
}
|
||||
|
||||
if interval < 604_800 {
|
||||
return I18n.Time.daysAgo(max(1, Int(interval / 86_400)))
|
||||
}
|
||||
|
||||
let calendar = Calendar.current
|
||||
if calendar.component(.year, from: date) == calendar.component(.year, from: now) {
|
||||
let formatter = DateFormatter()
|
||||
formatter.locale = Locale(identifier: LanguageHeaderProvider.current)
|
||||
formatter.timeZone = calendar.timeZone
|
||||
formatter.dateFormat = I18n.MainChat.monthDayDateFormat
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
|
||||
let formatter = DateFormatter()
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.timeZone = calendar.timeZone
|
||||
formatter.dateFormat = "yyyy.MM.dd"
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
|
||||
// 시도 순서: ISO8601(소수초 포함) → ISO8601 → RFC3339 유사 → 공백 구분 기본
|
||||
private static let parsers: [(String) -> Date?] = [
|
||||
|
||||
Reference in New Issue
Block a user