mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 18:45:22 +00:00
Location notes: append 'ago' to relative timestamps (within 7 days)
This commit is contained in:
@@ -122,7 +122,8 @@ struct LocationNotesView: View {
|
|||||||
let now = Date()
|
let now = Date()
|
||||||
if let days = Calendar.current.dateComponents([.day], from: date, to: now).day, days < 7 {
|
if let days = Calendar.current.dateComponents([.day], from: date, to: now).day, days < 7 {
|
||||||
// Relative (minute/hour/day), no seconds
|
// Relative (minute/hour/day), no seconds
|
||||||
return Self.relativeFormatter.string(from: date, to: now) ?? ""
|
let rel = Self.relativeFormatter.string(from: date, to: now) ?? ""
|
||||||
|
return rel.isEmpty ? "" : "\(rel) ago"
|
||||||
} else {
|
} else {
|
||||||
// Absolute date (MMM d or MMM d, yyyy if different year)
|
// Absolute date (MMM d or MMM d, yyyy if different year)
|
||||||
let sameYear = Calendar.current.isDate(date, equalTo: now, toGranularity: .year)
|
let sameYear = Calendar.current.isDate(date, equalTo: now, toGranularity: .year)
|
||||||
|
|||||||
Reference in New Issue
Block a user