mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-23 13:06:16 +00:00
Shorter date for status < to 24H
This commit is contained in:
parent
e53a3d0f61
commit
bfa717bfa2
1 changed files with 10 additions and 2 deletions
|
@ -6,9 +6,17 @@ private enum CodingKeys: CodingKey {
|
||||||
|
|
||||||
public struct ServerDate: Codable, Hashable, Equatable, Sendable {
|
public struct ServerDate: Codable, Hashable, Equatable, Sendable {
|
||||||
public let asDate: Date
|
public let asDate: Date
|
||||||
|
private let aDay: TimeInterval = 60 * 60 * 24
|
||||||
|
|
||||||
public var relativeFormatted: String {
|
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 {
|
public var shortDateFormatted: String {
|
||||||
|
|
Loading…
Reference in a new issue