Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/CodexBar/Date+RelativeDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ enum RelativeTimeFormatters {
@MainActor
static let full: RelativeDateTimeFormatter = {
let formatter = RelativeDateTimeFormatter()
formatter.locale = Locale(identifier: "en_US")
formatter.unitsStyle = .full
return formatter
}()
Expand Down
1 change: 1 addition & 0 deletions Sources/CodexBar/PreferencesGeneralPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ struct GeneralPane: View {
}
if let lastAttempt = self.store.tokenLastAttemptAt(for: provider) {
let rel = RelativeDateTimeFormatter()
rel.locale = Locale(identifier: "en_US")
rel.unitsStyle = .abbreviated
let when = rel.localizedString(for: lastAttempt, relativeTo: Date())
return Text("\(name): last attempt \(when)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public struct AugmentStatusSnapshot: Sendable {

private static func formatResetDate(_ date: Date) -> String {
let formatter = RelativeDateTimeFormatter()
formatter.locale = Locale(identifier: "en_US")
formatter.unitsStyle = .full
return formatter.localizedString(for: date, relativeTo: Date())
}
Expand Down
1 change: 1 addition & 0 deletions Sources/CodexBarCore/UsageFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public enum UsageFormatter {
if let hours = Calendar.current.dateComponents([.hour], from: date, to: now).hour, hours < 24 {
#if os(macOS)
let rel = RelativeDateTimeFormatter()
rel.locale = Locale(identifier: "en_US")
rel.unitsStyle = .abbreviated
return "Updated \(rel.localizedString(for: date, relativeTo: now))"
#else
Expand Down
1 change: 1 addition & 0 deletions Sources/CodexBarWidget/CodexBarWidgetViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ enum WidgetFormat {

static func relativeDate(_ date: Date) -> String {
let formatter = RelativeDateTimeFormatter()
formatter.locale = Locale(identifier: "en_US")
formatter.unitsStyle = .short
return formatter.localizedString(for: date, relativeTo: Date())
}
Expand Down
8 changes: 5 additions & 3 deletions Tests/CodexBarTests/UsageFormatterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ struct UsageFormatterTests {
let now = Date()
let fiveHoursAgo = now.addingTimeInterval(-5 * 3600)
let text = UsageFormatter.updatedString(from: fiveHoursAgo, now: now)
#expect(text.contains("Updated"))
// Check for relative time format (varies by locale: "ago" in English, "전" in Korean, etc.)
#expect(text.contains("5") || text.lowercased().contains("hour") || text.contains("시간"))
#expect(text.hasPrefix("Updated "))
// Output must stay in English regardless of the host system locale,
// matching the surrounding hardcoded English UI labels.
#expect(text.contains("5"))
#expect(text.lowercased().contains("ago"))
}

@Test
Expand Down