damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit f05cd1b7e6b29ad5fdc387d49320965ca1d87724
parent b73b1da46e01b46e7f4a60f57da6debef3b65ccf
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 30 Jan 2024 19:01:31 -0800

split up date formatting

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Views/EventView.swift | 8++++++--
Mdamus/Views/Events/SelectedEventView.swift | 2+-
Mdamus/Views/Purple/DamusPurpleView.swift | 4++--
3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift @@ -76,10 +76,14 @@ func format_relative_time(_ created_at: UInt32) -> String return time_ago_since(Date(timeIntervalSince1970: Double(created_at))) } -func format_date(_ created_at: UInt32) -> String { +func format_date(created_at: UInt32) -> String { let date = Date(timeIntervalSince1970: TimeInterval(created_at)) + return format_date(date: date) +} + +func format_date(date: Date, time_style: DateFormatter.Style = .short) -> String { let dateFormatter = DateFormatter() - dateFormatter.timeStyle = .short + dateFormatter.timeStyle = time_style dateFormatter.dateStyle = .short return dateFormatter.string(from: date) } diff --git a/damus/Views/Events/SelectedEventView.swift b/damus/Views/Events/SelectedEventView.swift @@ -57,7 +57,7 @@ struct SelectedEventView: View { Mention - Text(verbatim: "\(format_date(event.created_at))") + Text(verbatim: "\(format_date(created_at: event.created_at))") .padding([.top, .leading, .trailing]) .font(.footnote) .foregroundColor(.gray) diff --git a/damus/Views/Purple/DamusPurpleView.swift b/damus/Views/Purple/DamusPurpleView.swift @@ -308,14 +308,14 @@ struct DamusPurpleView: View { Text(NSLocalizedString("Purchased on", comment: "Indicating when the user purchased the subscription")) .font(.title2) .foregroundColor(.white) - Text(format_date(UInt32(purchased.tx.purchaseDate.timeIntervalSince1970))) + Text(format_date(date: purchased.tx.purchaseDate)) .foregroundColor(.white) .opacity(0.65) if let expiry = purchased.tx.expirationDate { Text(NSLocalizedString("Renews on", comment: "Indicating when the subscription will renew")) .font(.title2) .foregroundColor(.white) - Text(format_date(UInt32(expiry.timeIntervalSince1970))) + Text(format_date(date: expiry)) .foregroundColor(.white) .opacity(0.65) }