split up date formatting
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user