Correct weekday names in schedule labels

This commit is contained in:
Ian Gulliver
2026-10-21 15:59:24 -07:00
parent 0e5480b1a5
commit 6729336cb3
+2 -2
View File
@@ -7,7 +7,7 @@ typealias ScheduleEvery = Components.Schemas.ScheduleEvery
typealias Weekday = Components.Schemas.Weekday typealias Weekday = Components.Schemas.Weekday
private let weekdayNames: [(Weekday, String, String)] = [ private let weekdayNames: [(Weekday, String, String)] = [
(.mon, "M", "Mon"), (.tue, "T", "Tue"), (.wed, "W", "Wed"), (.thu, "T", "Thu"), (.fri, "F", "Fri"), (.sat, "S", "Sat"), (.sun, "S", "Sun"), (.mon, "M", "Monday"), (.tue, "T", "Tuesday"), (.wed, "W", "Wednesday"), (.thu, "T", "Thursday"), (.fri, "F", "Friday"), (.sat, "S", "Saturday"), (.sun, "S", "Sunday"),
] ]
private func twoDigits(_ n: Int) -> String { private func twoDigits(_ n: Int) -> String {
@@ -42,7 +42,7 @@ func scheduleTiming(_ sc: Schedule) -> String {
return "Weekends at \(at)" return "Weekends at \(at)"
} }
let names = weekdayNames.filter { days.contains($0.0) }.map(\.2) let names = weekdayNames.filter { days.contains($0.0) }.map(\.2)
return names.count == 1 ? "\(names[0])days at \(at)" : "\(names.joined(separator: ", ")) at \(at)" return names.count == 1 ? "\(names[0])s at \(at)" : "\(names.map { String($0.prefix(3)) }.joined(separator: ", ")) at \(at)"
case .month: case .month:
return "Monthly on the \(ordinal(sc.dayOfMonth)) at \(at)" return "Monthly on the \(ordinal(sc.dayOfMonth)) at \(at)"
} }