Skip to content

fix(ui): overnight class times render as two full dates - #333

Merged
sydevs-bot merged 10 commits into
mainfrom
claude/fix-325-overnight-time-range
Oct 26, 2026
Merged

sydevs-bot merged 10 commits into
mainfrom
claude/fix-325-overnight-time-range

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A class ending after midnight now reads 9:30 PM – 12:30 AM instead of two full dates.
  • Each locale keeps its own range pattern across midnight — German's "Uhr", Japanese's 時/分.
  • Joined: the mocks had no overnight session, so the fix had no surface to look at. One fixture and one story section, plus two fixture comments the fix made untrue.

Change outline

Behaviour — formatTimeRange

Intl.DateTimeFormat#formatRange widens 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, always

The 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

 the one caller passing an end                            src/hooks/use-event-display.ts
-  eventEnd = nextEnd.setZone(eventStart.zone)            # reconciled a second time, here
-  formatTimeRange(eventStart, …eventEnd…)
+  formatTimeRange(eventStart, …nextEnd…)                 # the formatter is the only owner

Preview

  • Event Facts → "Past midnight" — the fixed line, on a 21:30–00:30 fixture. Scroll to the Past midnight section, between "Online" and "Course". The story runs on mockEventOvernight, so there is nothing to seed. Switch the playground's locale to read the German and Japanese rows in step 2 below.
  • The app — the branch alias, serving this commit. It opens on the live region list, but it cannot be relied on to show the fix: that needs a published class whose endTime precedes 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

  • Lean gate: ✓ lint, typecheck, test:run (1771 tests, 149 files)
  • Targeted specs: src/lib/time.test.ts 22 passed, src/hooks/use-event-display.test.ts 5 passed — 4 of the time cases new, each watched failing against origin/main's time.ts
  • Build: N/A — left to CI

Manual verification

  1. Open the playground story above and read the Past midnight row: one time range, no dates.
  2. Switch the playground's locale to German and Japanese and read the same row — 21:30–00:30 Uhr, 21時30分~0時30分.
  3. On the app, any published class with an endTime before 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

  • The first draft of this took the approach the ticket describes — split the range, format each end, rejoin with the separator. /code-review found two defects in it, and both are why the mechanism changed. Basque's fallback pattern is 2026/10/27 (21:30) – …, so its first shared literal is ") – " and the class read 21:30) – 0:30. And leaving formatRange behind lost the range pattern itself: German dropped "Uhr", Japanese dropped 時/分, and the spec I had written pinned that degraded string as correct.
  • The same-day path is byte-identical, measured across 288 ranges — 72 locales by four cases (on the hour, with minutes, crossing noon, a long daytime span).
  • formatRange is 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, and wallClockOnOneDay's doc now names the two repairs that would break the fix.
  • Dismissed, with reasons: the /simplify pass proposed replacing a day check with luxon's hasSame; 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.
  • The ticket says the pin popover was affected. It is not: Map.tsx renders eventStartTime, 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 through EventFacts.
  • A fix was said to exist on 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 leaves formatRange doing 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 → the live/today status (a 21:30–00:30 class must stay live until 00:30), the Schedule-X calendar block's end, and DTEND on every exported VEVENT. Clamping the end to the start's day would make the occurrence finish before it begins.

Fixture pre-mortem. mockEventOvernight assumes the CMS's own overnight shape — an endTime wall-clock string earlier than the start, which withEndTime (src/lib/shape/event.ts:135) rolls to the next day. Checked against that function, not assumed. Verified end to end through resolveEventDisplay: the fixture's next session runs 2026-10-30T21:30 → 2026-10-31T00:30 and renders 9: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 from scripts/assert-preview-host.mjs's pinned WORKERS_SUBDOMAIN. The assembled host was then confirmed rather than trusted — the deployed EventFacts story chunk on it contained Past midnight, so it was this branch's build, and the story id molecules--event-facts was read out of the deployed entry bundle rather than derived from Ladle's naming rules.

Security review: skipped — neither securityReview.triggerPattern nor contentPattern matches any changed file. Comment lint: clean, re-run after the review round. Docs sync: CHANGELOG.md carries the visible-behaviour entry; nothing else in docs/ or any AGENTS.md describes this formatting, the fixture ids or the call site.

Closes #325

🤖 Generated with Claude Code

https://claude.ai/code/session_01WNyei4FNiqV8xLUK1J7bK1

`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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 671921f Oct 26 2026, 02:03 PM

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 26, 2026
@sydevs-bot

sydevs-bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 13:53Z address-review · attempt 1 · session · done
  • 13:53Z address-review · attempt 1 · session
  • 13:41Z review-pr · attempt 1 · session · done
  • 13:41Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

This draft has had no CI activity for hours and no session holds it. A mention (@sydevs-bot) or a push from you starts me again.

🤖 sydevs dispatcher

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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: mockEventOvernight takes id: 126, which mockEventInactive already holds. src/mocks/events.ts:232
  • should-fix — src/lib/time.test.ts:7-9 still says the formatter's timeZone comes from the DateTime; it is hard-coded 'UTC' now. No thread: that line is outside every hunk.
  • consider — the reversed formatRange pair is unexplained. src/lib/time.ts:98
  • consider — endInZone duplicates the one caller's own setZone. src/lib/time.ts:87
  • consider — the JSDoc explaining formatTimeRange sits 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: withEndTime rolls at most +1 day, and the one caller passing an end guards on schedule.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 ## Preview links return 200, and the playground bundle does carry Past midnight.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/mocks/events.ts Resolved
Comment thread src/lib/time.ts Resolved
Comment thread src/lib/time.ts Resolved
Comment thread src/lib/time.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 26, 2026
`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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

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

View logs

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Four review threads, all adopted. The branch already contained origin/main, so there was no base merge.

The review's fifth finding had no thread: time.test.ts's header still claimed the formatter's timeZone comes from the DateTime. Corrected in 671921f.

Lean gate green: lint, typecheck, 1771 tests in 149 files.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 26, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 26, 2026 14:06
@sydevs-bot
sydevs-bot requested a review from Ardnived October 26, 2026 14:06
@sydevs-bot
sydevs-bot enabled auto-merge October 26, 2026 14:06
@sydevs-bot sydevs-bot moved this from Revising to Approved in SYDevelopers Technical Roadmap Oct 26, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 0fe62a9 Oct 26, 2026
74 of 79 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-325-overnight-time-range branch October 26, 2026 19:58
@sydevs-bot sydevs-bot moved this from Approved to Done in SYDevelopers Technical Roadmap Oct 26, 2026
sydevs-bot pushed a commit that referenced this pull request Oct 26, 2026
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(ui): overnight class times render as two full dates

3 participants