diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f6a00..989efc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,15 @@ automatically and used as the GitHub Release notes. ## [Unreleased] +## [1.0.13] - 2026-07-21 + +### Changed + +- Show only the month name in Year chart detail headers because each bar + represents a whole calendar month. + +## [1.0.12] - 2026-07-21 + ### Fixed - Fetch every page of yearly Upwork time-report data so the Year dashboard diff --git a/Sources/UpworkBuddy/Info.plist b/Sources/UpworkBuddy/Info.plist index 4dced4c..c4e06f5 100644 --- a/Sources/UpworkBuddy/Info.plist +++ b/Sources/UpworkBuddy/Info.plist @@ -33,9 +33,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.12 + 1.0.13 CFBundleVersion - 13 + 14 LSMinimumSystemVersion 14.0 LSUIElement diff --git a/Sources/UpworkBuddy/Views/DashboardView.swift b/Sources/UpworkBuddy/Views/DashboardView.swift index dd7ec05..b22c158 100644 --- a/Sources/UpworkBuddy/Views/DashboardView.swift +++ b/Sources/UpworkBuddy/Views/DashboardView.swift @@ -43,7 +43,8 @@ struct DashboardView: View { currency: store.currency, masked: store.hideSensitive, metric: store.dashboardMetric, - title: chartTitle + title: chartTitle, + period: store.selectedPeriod ) .zIndex(2) } diff --git a/Sources/UpworkBuddy/Views/SparklineView.swift b/Sources/UpworkBuddy/Views/SparklineView.swift index 84f6aed..effa3f7 100644 --- a/Sources/UpworkBuddy/Views/SparklineView.swift +++ b/Sources/UpworkBuddy/Views/SparklineView.swift @@ -1,11 +1,27 @@ import SwiftUI +enum SparklineDateLabelFormatter { + static func string( + for date: Date, + period: Period, + locale: Locale = L10n.currentLocale, + timeZone: TimeZone = .current + ) -> String { + let formatter = DateFormatter() + formatter.locale = locale + formatter.timeZone = timeZone + formatter.setLocalizedDateFormatFromTemplate(period == .year ? "MMM" : "EEE MMM d") + return formatter.string(from: date) + } +} + struct SparklineView: View { let points: [DailyPoint] let currency: String var masked: Bool = false var metric: MenuBarMetric = .earnings var title: String? + let period: Period @State private var hoverIndex: Int? @@ -108,15 +124,12 @@ struct SparklineView: View { } private func tooltip(for point: DailyPoint, format: CurrencyFormat) -> some View { - let f = DateFormatter() - f.locale = L10n.currentLocale - f.setLocalizedDateFormatFromTemplate("EEE MMM d") let rows = Array(point.breakdown.prefix(5)) let isPayoutOnly = point.earnings > 0 && point.hours <= 0.01 let primaryValue = metric == .hours ? point.hours.asHours() : format.compact(point.earnings) return VStack(alignment: .leading, spacing: 4) { HStack { - Text(f.string(from: point.date)) + Text(SparklineDateLabelFormatter.string(for: point.date, period: period)) .font(Theme.body(size: 11, weight: .semibold)) .foregroundStyle(Theme.textPrimary) if isPayoutOnly { diff --git a/Tests/UpworkBuddyTests/SparklineDateLabelTests.swift b/Tests/UpworkBuddyTests/SparklineDateLabelTests.swift new file mode 100644 index 0000000..8f05b77 --- /dev/null +++ b/Tests/UpworkBuddyTests/SparklineDateLabelTests.swift @@ -0,0 +1,39 @@ +import Foundation +import Testing +@testable import UpworkBuddy + +@Suite("Sparkline date labels") +struct SparklineDateLabelTests { + private let locale = Locale(identifier: "en_US_POSIX") + private let timeZone = TimeZone(secondsFromGMT: 0)! + + @Test func yearUsesMonthNameOnly() { + let label = SparklineDateLabelFormatter.string( + for: juneFirst2026, + period: .year, + locale: locale, + timeZone: timeZone + ) + + #expect(label == "Jun") + } + + @Test func shorterPeriodsKeepWeekdayAndDay() { + let label = SparklineDateLabelFormatter.string( + for: juneFirst2026, + period: .month, + locale: locale, + timeZone: timeZone + ) + + #expect(label.contains("Mon")) + #expect(label.contains("Jun")) + #expect(label.contains("1")) + } + + private var juneFirst2026: Date { + var calendar = Calendar(identifier: .gregorian) + calendar.timeZone = timeZone + return calendar.date(from: DateComponents(year: 2026, month: 6, day: 1))! + } +} diff --git a/VERSION b/VERSION index bb83058..2ac9634 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.12 +1.0.13