fix: show 'Just now' instead of '1s ago' after refresh
Replaced RelativeDateTimeFormatter with manual formatting: <5s → 'Just now', <60s → 'Xs ago', <1h → 'Xm ago', <1d → 'Xh ago', else 'Xd ago'. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
07ac29faa6
commit
2f2a65f1f7
|
|
@ -110,9 +110,20 @@ struct BugListPopover: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func formatted(_ date: Date) -> String {
|
private func formatted(_ date: Date) -> String {
|
||||||
let formatter = RelativeDateTimeFormatter()
|
let seconds = Int(Date().timeIntervalSince(date))
|
||||||
formatter.unitsStyle = .abbreviated
|
switch seconds {
|
||||||
return formatter.localizedString(for: date, relativeTo: Date())
|
case ..<5: return "Just now"
|
||||||
|
case ..<60: return "\(seconds)s ago"
|
||||||
|
case ..<3600:
|
||||||
|
let m = seconds / 60
|
||||||
|
return m == 1 ? "1m ago" : "\(m)m ago"
|
||||||
|
case ..<86400:
|
||||||
|
let h = seconds / 3600
|
||||||
|
return h == 1 ? "1h ago" : "\(h)h ago"
|
||||||
|
default:
|
||||||
|
let d = seconds / 86400
|
||||||
|
return d == 1 ? "1d ago" : "\(d)d ago"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue