chore: update timestamp style
This commit is contained in:
parent
ddd1d0f6e4
commit
1017dd34e1
|
@ -18,24 +18,27 @@ extension Date {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var localizedSlowedTimeAgoSinceNow: String {
|
var localizedSlowedTimeAgoSinceNow: String {
|
||||||
return self.localizedTimeAgo(since: Date(), isSlowed: true)
|
return self.localizedTimeAgo(since: Date(), isSlowed: true, isAbbreviated: true)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var localizedTimeAgoSinceNow: String {
|
var localizedTimeAgoSinceNow: String {
|
||||||
return self.localizedTimeAgo(since: Date(), isSlowed: false)
|
return self.localizedTimeAgo(since: Date(), isSlowed: false, isAbbreviated: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func localizedTimeAgo(since date: Date, isSlowed: Bool) -> String {
|
func localizedTimeAgo(since date: Date, isSlowed: Bool, isAbbreviated: Bool) -> String {
|
||||||
let earlierDate = date < self ? date : self
|
let earlierDate = date < self ? date : self
|
||||||
let latestDate = earlierDate == date ? self : date
|
let latestDate = earlierDate == date ? self : date
|
||||||
|
|
||||||
if isSlowed, earlierDate.timeIntervalSince(latestDate) >= -60 {
|
if isSlowed, earlierDate.timeIntervalSince(latestDate) >= -60 {
|
||||||
return L10n.Common.Controls.Timeline.Timestamp.now
|
return L10n.Common.Controls.Timeline.Timestamp.now
|
||||||
|
} else {
|
||||||
|
if isAbbreviated {
|
||||||
|
return latestDate.shortTimeAgo(since: earlierDate)
|
||||||
} else {
|
} else {
|
||||||
return Date.relativeTimestampFormatter.localizedString(for: earlierDate, relativeTo: latestDate)
|
return Date.relativeTimestampFormatter.localizedString(for: earlierDate, relativeTo: latestDate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue