Shorter date for status < to 24H
This commit is contained in:
parent
e53a3d0f61
commit
bfa717bfa2
|
@ -6,9 +6,17 @@ private enum CodingKeys: CodingKey {
|
|||
|
||||
public struct ServerDate: Codable, Hashable, Equatable, Sendable {
|
||||
public let asDate: Date
|
||||
private let aDay: TimeInterval = 60 * 60 * 24
|
||||
|
||||
public var relativeFormatted: String {
|
||||
DateFormatterCache.shared.createdAtRelativeFormatter.localizedString(for: asDate, relativeTo: Date())
|
||||
let date = asDate
|
||||
if Date().timeIntervalSince(date) >= aDay {
|
||||
return DateFormatterCache.shared.createdAtRelativeFormatter.localizedString(for: date,
|
||||
relativeTo: Date())
|
||||
} else {
|
||||
return Duration.seconds(-date.timeIntervalSinceNow).formatted(.units(width: .narrow,
|
||||
maximumUnitCount: 1))
|
||||
}
|
||||
}
|
||||
|
||||
public var shortDateFormatted: String {
|
||||
|
|
Loading…
Reference in New Issue