uttrflow / uttrflow/uttrflow-swift
Insights' "Charts appear on…" counts days as 86,400 seconds and ignores its calendar, so it names the wrong weekday across a daylight-saving change
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
`InsightsPresenter.remaining(spoken:now:calendar:locale:)` (`Sources/UttrflowUX/InsightsPresentation.swift:357-362`) works out the day charts appear by adding flat seconds, and never uses the `calendar` it is passed:
```swift
let day = now.addingTimeInterval(Double(left) * 86_400)
return "Charts appear on \(day.formatted(.dateTime.weekday(.wide).locale(locale)))"
```
On a day that is 23 hours long (clocks going forward), adding 86,400 seconds late in the evening lands after midnight of the following day, so the page names a weekday one too late. The weekday is also formatted in the process's time zone rather than the calendar's, so a test calendar and the output can disagree.
## Why it matters
A small, visible wrong fact on the page a new user checks while waiting for their first week. It is also the one place in `InsightsPresentation.swift` that does day arithmetic by seconds; the bars (lines 212-214) already use `calendar.date(byAdding: .day, …)`.
## How to reproduce (headless)
```swift
var calendar = Calendar(identifier: .gregorian)
calendar.timeZone = TimeZone(identifier: "America/New_York")!
// Saturday 7 March 2026, 23:30; clocks go forward at 02:00 on Sunday 8 March
let now = calendar.date(from: DateComponents(year: 2026, month: 3, day: 7, hour: 23, minute: 30))!
InsightsPresenter.remaining(spoken: 6, now: now, calendar: calendar, locale: Locale(identifier: "en_US"))
```
Run with `TZ=America/New_York swift test --filter …`: on main (26d7bc1) this returns "Charts appear on Monday"; one day on from Saturday is Sunday.
## Acceptance criteria
- `remaining` uses `calendar.date(byAdding: .day, value: left, to: now)` and formats the weekday in the calendar's time zone.
- A test in `Tests/UttrflowUXTests/InsightsPresentationTests.swift` covers a spring-forward evening and passes whatever the machine's time zone is.
## Where to start
- `Sources/UttrflowUX/InsightsPresentation.swift`, `remaining(spoken:now:calendar:locale:)`.
- Extend `Tests/UttrflowUXTests/InsightsPresentationTests.swift`; build a `Calendar` with a fixed `timeZone` and pass it in, and format with `Date.FormatStyle(timeZone:)` or set `calendar` on the style so the test does not depend on the runner.
- Run `make verify` before opening a pull request; see CONTRIBUTING.md.
Size: small, about 5 lines plus one test.
Contributor guide
Research direction
Start in Sources/UttrflowUX/InsightsPresentation.swift at remaining(spoken:now:calendar:locale:), then extend Tests/UttrflowUXTests/InsightsPresentationTests.swift with the fixed-time-zone spring-forward case described in the issue. Run the focused test and make verify; done means the weekday is calendar-based and the test passes regardless of the machine time zone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100