Repository navigation
fix(ui): overnight class times render as two full dates - #333
Conversation
`Intl.DateTimeFormat#formatRange` widens its pattern to disambiguate endpoints that fall on different calendar days, so a 21:30–00:30 session came back as "10/27/2026, 9:30 PM – 10/28/2026, 12:30 AM" on the class page and the list cards. Nothing turns that widening off. Detect it from the formatter's own output — any date field in `formatRangeToParts` — then format each endpoint on its own and rejoin them with the separator the range itself used, so the locale keeps its own conventions (Japanese gets its wave dash, not an en dash). Reading the parts rather than comparing calendar days keeps the decision in the formatter's zone and avoids shifting an instant across a DST boundary. An occurrence spans at most one night (`withEndTime` rolls an earlier end to the next day), so the dates it added never carried information. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WNyei4FNiqV8xLUK1J7bK1
A host sees the rendered time, so the visible-behaviour section carries it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WNyei4FNiqV8xLUK1J7bK1
Read the time-only part types as an allowlist, so a part type the check does not know takes the split path (a correct time range) instead of re-opening #325. Join the parts the probe already holds rather than formatting the range a second time: measured 24µs against 49µs per call, where the unprobed original was 21µs. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WNyei4FNiqV8xLUK1J7bK1
The review pass found two defects in splitting the range apart and rejoining it by hand. Basque's fallback pattern puts a bracket in the shared literal, so the first one is ") – " and a 21:30–00:30 class read "21:30) – 0:30". And leaving formatRange behind lost the range pattern itself: German dropped its "Uhr" and Japanese its 時/分. Put both wall clocks on one fixed calendar day instead, so formatRange never widens its pattern and every locale keeps its own. The day is in UTC: re-dating the end onto the start's day looks simpler, but London skips 01:00–02:00 on 2026-03-29, where luxon renders a 01:30 end as 02:30. Measured byte-identical to the previous output on 288 same-day ranges, 72 locales by four cases. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WNyei4FNiqV8xLUK1J7bK1
The story playground had no overnight session to look at, so the fix had no surface a reviewer could open. `mockEventOvernight` is a 21:30–00:30 weekly class, and EventFacts gains a section for it. The two fixture comments above it claimed a same-day end was what kept the time line free of dates. It no longer is, so they now say what they are really avoiding: a 17-hour span inherited from another fixture. Verified through resolveEventDisplay: the fixture's next session runs 2026-10-30T21:30 to 2026-10-31T00:30 and renders "9:30 PM – 12:30 AM" in en-US, "21:30–00:30 Uhr" in de. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WNyei4FNiqV8xLUK1J7bK1
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajatlas-design | 671921f | Oct 26 2026, 02:03 PM |
|
This draft has had no CI activity for hours and no session holds it. A mention ( 🤖 sydevs dispatcher |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the size of the ticket and no larger, and the fixture and story are the fix's only visible surface, so the join is right. No blocker.
The mechanism beats the ticket's: splitting the range and rejoining by hand loses the locale's range pattern. Nothing in the platform suppresses the widening, and luxon's Interval#toLocaleString delegates to the same formatRange — so the pinned fake day is the available answer, not an invented layer. It leans on something undocumented, though: formatRange gets a start later than its end on every overnight range, and no spec or MDN text covers that pair.
Findings
- should-fix — duplicate fixture id:
mockEventOvernighttakesid: 126, whichmockEventInactivealready holds.src/mocks/events.ts:232 - should-fix —
src/lib/time.test.ts:7-9still says the formatter'stimeZonecomes from the DateTime; it is hard-coded'UTC'now. No thread: that line is outside every hunk. - consider — the reversed
formatRangepair is unexplained.src/lib/time.ts:98 - consider —
endInZoneduplicates the one caller's ownsetZone.src/lib/time.ts:87 - consider — the JSDoc explaining
formatTimeRangesits 69 lines from it.src/lib/time.ts:16
What was checked
- Read whole:
time.ts,time.test.ts,mocks/events.ts,EventFacts.stories.tsx,lib/shape/event.ts,use-event-display.ts:230-245. - The "at most one night" premise holds:
withEndTimerolls at most+1 day, and the one caller passing an end guards onschedule.endTime. - Same-day path re-measured old against new: 72 locales × 5 zones (Pacific/Chatham's :45 in) × 6 ranges, zero differences in 2160.
- Overnight path over those 72 locales: no date anywhere, each its own pattern.
- Both
## Previewlinks return 200, and the playground bundle does carryPast midnight.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`mockEventOvernight` took id 126, which `mockEventInactive` already holds, and `mockEventVariants` hard-codes that id into the inactive venue's path. Two fixtures answering to one id is a trap for the next list or id lookup that collects them. 129 was free. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CXpNukvWSPaNcFt22ijrwz
The call site reconciled the end instant's zone itself, and `formatTimeRange` now does the same thing internally, so neither read as the owner. The formatter needs the wall clock either way, so it takes either zone and the caller hands over `nextEnd` plain. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CXpNukvWSPaNcFt22ijrwz
The block explaining why this delegates to `Intl` sat at the top of the file, 69 lines above the function it describes and with `sameWallClock`'s own JSDoc wedged in between, so it documented nothing. It now sits on `formatTimeRange` and absorbs the one conclusion the pinning comment was repeating. `wallClockOnOneDay` keeps the mechanism: the day boundary that widens the pattern, the at-most-one-night premise that makes the dates discardable, and the UTC day that no transition can shift. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CXpNukvWSPaNcFt22ijrwz
Every overnight range hands `formatRange` a start later than its end, and neither ECMA-402's PartitionDateTimeRangePattern nor MDN says what that does. It renders correctly in every locale checked, but it reads as a defect, and the two obvious repairs both break the fix: re-dating the end restores the day boundary the pinning exists to remove, and swapping the arguments prints the range backwards. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CXpNukvWSPaNcFt22ijrwz
The spec header said the fixed zone kept the formatter's `timeZone` deterministic, "taken from the DateTime". It is hard-coded UTC now. What the fixed zone still decides is each endpoint's wall clock, and the zone a cross-zone end is converted into. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CXpNukvWSPaNcFt22ijrwz
Deploying sahajatlas with
|
| Latest commit: |
671921f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5db3d30e.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-fix-325-overnight-tim.sahajatlas.pages.dev |
|
Four review threads, all adopted. The branch already contained
The review's fifth finding had no thread: Lean gate green: lint, typecheck, 1771 tests in 149 files. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
#333 and this branch each added the newest entry under `### Fixed`, so the add/add conflict in CHANGELOG.md took both, this PR's #320 entry first because it lands after #325. Both link definitions survived the automatic merge. No other file overlapped: main's #333 touched `src/lib/time*`, `use-event-display`, `EventFacts.stories` and `src/mocks/events.ts`, which only gained `mockEventOvernight`. Lean gate green on the merge — 151 files, 1780 tests. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PvgLPoQcs7LuvyYwthzPFy
Summary
9:30 PM – 12:30 AMinstead of two full dates.Change outline
Behaviour —
formatTimeRangeIntl.DateTimeFormat#formatRangewidens its pattern to a full date on each end as soon as the two instants fall on different calendar days, and no option turns that off. So the endpoints are re-pinned to one calendar day before they are formatted, and the range pattern never widens.formatTimeRange(start, end, locale) src/lib/time.ts onTheHour ? {hour} : {hour, minute} - formatter timeZone = start's own zone - formatRange(start, end) - different calendar days → a full date on each end # 21:30–00:30 → "10/27/2026, 9:30 PM – 10/28/2026, 12:30 AM" + read end's wall clock in the START's zone # a caller may hand over either zone + formatter timeZone = UTC + wallClockOnOneDay(at) → 2000-01-01T<at.hour>:<at.minute>Z + formatRange(startClock, endClock) + one calendar day either way → the locale's hour-range pattern, alwaysThe 2000-01-01 day is in UTC on purpose. Re-dating the end onto the start's own day looks simpler and is wrong one night a year: London skips 01:00–02:00 on 2026-03-29, where luxon renders a 01:30 end as 02:30.
Ownership — who reconciles the end's zone
Preview
mockEventOvernight, so there is nothing to seed. Switch the playground's locale to read the German and Japanese rows in step 2 below.endTimeprecedes its start, and the feed refused an unauthenticated read (403), so whether production has one is unknown from here. The playground link above is the one that shows the change.Test results
test:run(1771 tests, 149 files)src/lib/time.test.ts22 passed,src/hooks/use-event-display.test.ts5 passed — 4 of the time cases new, each watched failing againstorigin/main'stime.tsManual verification
21:30–00:30 Uhr,21時30分~0時30分.endTimebefore its start time (the CMS rolls it to the next day), on its class page and in a result card. This is the one step the automated lanes cannot reach, and the one the 403 above left unverified.Notes for reviewer
/code-reviewfound two defects in it, and both are why the mechanism changed. Basque's fallback pattern is2026/10/27 (21:30) – …, so its first shared literal is") – "and the class read21:30) – 0:30. And leavingformatRangebehind lost the range pattern itself: German dropped "Uhr", Japanese dropped 時/分, and the spec I had written pinned that degraded string as correct.formatRangeis handed a start later than its end on every overnight range, and no spec or MDN text covers that pair. Measured correct across 74 locales, andwallClockOnOneDay's doc now names the two repairs that would break the fix./simplifypass proposed replacing a day check with luxon'shasSame; the mechanism that landed makes no day comparison at all, so the finding no longer applies. It also proposed dropping an unreachable' – 'separator fallback — that code is gone too.Map.tsxrenderseventStartTime, the start alone, which never had an end to disagree with. Nothing else to do — the class page and the list cards were the two real surfaces, and both go throughEventFacts.ux/147-a-one-sheet. That branch is not on the remote, so nothing was ported from it.Detail
Why the probe-the-output approach was dropped. An intermediate version asked the formatter what it had emitted (
formatRangeToParts, then a date-field check) rather than predicting when it widens. That read well and cost 24µs against the original 21µs, but it still had to rejoin the two ends by hand, which is what carried both of the review's defects. Re-pinning the day leavesformatRangedoing the whole job, so there is nothing left to rejoin.Why the fix is in the formatter and not upstream. The cross-day end instant is correct data, and three consumers depend on it:
occurrenceEnd→ thelive/todaystatus (a 21:30–00:30 class must stay live until 00:30), the Schedule-X calendar block's end, andDTENDon every exportedVEVENT. Clamping the end to the start's day would make the occurrence finish before it begins.Fixture pre-mortem.
mockEventOvernightassumes the CMS's own overnight shape — anendTimewall-clock string earlier than the start, whichwithEndTime(src/lib/shape/event.ts:135) rolls to the next day. Checked against that function, not assumed. Verified end to end throughresolveEventDisplay: the fixture's next session runs2026-10-30T21:30→2026-10-31T00:30and renders9:30 PM – 12:30 AM.How the preview links were established. The app's host is the branch alias read off the Cloudflare Pages check summary, never the per-commit one. The playground is on Workers, whose check run and bot comment publish only dashboard links, so no comment on this PR carries its host: the preview name comes from that check's own dashboard path, the Worker name from
wrangler.design.jsonc, and the account subdomain fromscripts/assert-preview-host.mjs's pinnedWORKERS_SUBDOMAIN. The assembled host was then confirmed rather than trusted — the deployedEventFactsstory chunk on it containedPast midnight, so it was this branch's build, and the story idmolecules--event-factswas read out of the deployed entry bundle rather than derived from Ladle's naming rules.Security review: skipped — neither
securityReview.triggerPatternnorcontentPatternmatches any changed file. Comment lint: clean, re-run after the review round. Docs sync:CHANGELOG.mdcarries the visible-behaviour entry; nothing else indocs/or anyAGENTS.mddescribes this formatting, the fixture ids or the call site.Closes #325
🤖 Generated with Claude Code
https://claude.ai/code/session_01WNyei4FNiqV8xLUK1J7bK1