Repository navigation
Backlog
Description
Summary
On the English page, dates and times follow the visitor's browser region (#509), but two regions slip back to US formats:
- No English data for the region. CLDR has no English for Brazil, Russia, Türkiye, Mexico, Egypt or China. A browser whose first language is pt-BR, ru-RU, tr-TR, es-MX, ar-EG or zh-CN gets its own clock, but US month-first dates: "Fri, Nov 13", where its own order is "Fri 13 Nov".
- No Schedule-X strings for the region. Schedule-X bundles only en-GB and en-US English, so an en-AU, en-NZ or en-IN visitor's calendar grid runs as en-GB on a 24-hour clock ("17:45"), while the lists beside it read "5:45 pm".
Both come from one cause: a regional English tag that the data behind it can't serve. So they share one fix and one check.
Approach
1. Pick the English base by the browser's own date order (inBrowserRegion, src/lib/time.ts).
- Today:
inBrowserRegionbuildsen-<region>and adds-u-hc-<cycle>when the clock differs (en-BR-u-hc-h23). Intl then resolvesen-BRto plainen, which is US date order. - Detect it:
new Intl.DateTimeFormat(tag).resolvedOptions().localehas dropped the region (measured in Node 26 / ICU:en-BR,en-RU,en-TR,en-MX,en-EGanden-CNall resolve toen;en-CZ,en-DEanden-JPkeep theirs). - Fix: when the region was dropped, base the tag on
en-GBoren-USby the browser locale's own day/month order, then add-u-hc-as today: pt-BR becomesen-GB-u-hc-h23, zh-CN becomesen-US-u-hc-h23. The day-first probe already exists asdayFirstbesidescheduleXLocaleinsrc/lib/shape/calendar.ts; share it rather than copy it. - ⚠ Keep miles right.
usesMiles(src/lib/distance.ts) reads the format locale's region, so a Brazilianen-GB-…tag would read miles. Carry the browser's real region where it can still be read, for example-u-rg-<region>zzzz. Check what Intl and luxon do withrgbefore relying on it. Otherwise giveusesMilesthe region another way. Miles stay limited to a US or UK region.
2. Keep the calendar grid on the lists' clock (scheduleXLocale, src/lib/shape/calendar.ts, and the patch patches/@[email protected]).
- Today:
scheduleXLocalemaps any regional English toen-GBoren-USby date order. That keeps the date order, but gives the grid that locale's clock. - Why it can't just pass the tag: Schedule-X checks
localeagainst^[a-z]{2}-[A-Z]{2}$(node_modules/@schedule-x/calendar/dist/core.js, around line 5065), and a tag with no bundled strings renders the raw keys. So it can't takeen-AUoren-GB-u-hc-h12as it stands. - Fix: let the grid carry the lists' hour cycle. Either relax that check in the existing patch so
en-GB-u-hc-h12passes and is used for time formatting while the strings stay underenGB, or set Schedule-X's own time-format options from the format locale'shourCycle. Pick whichever changes less of Schedule-X. Record the choice in the patch register (src/components/AGENTS.md§ Patch register) if the patch grows. - Cover both directions: after the fix, the grid matches the lists for en-AU (12-hour), and for a 24-hour region that runs as en-US (zh-CN).
Tests: src/lib/time.test.ts (regionalLocale) and src/lib/shape/calendar.test.ts (scheduleXLocale) pin the cases below. src/lib/distance.test.ts pins miles for each new tag shape.
Acceptance criteria
- On an English page, a browser whose first language is pt-BR, ru-RU or tr-TR reads dates day-first ("Fri 13 Nov") on its own 24-hour clock ("17:45").
- es-MX and ar-EG read day-first dates on their own 12-hour clock.
- zh-CN reads month-first dates on a 24-hour clock.
- Regions CLDR has English for (en-CZ, en-DE, en-GB, en-US) read exactly as on main.
- In the calendar grid, en-AU, en-NZ and en-IN read the same clock as the lists ("5:45 pm"). A 24-hour region that runs as en-US reads 24-hour times in the grid.
- Distances still read miles only for a US or UK region. A pt-BR, ru-RU or en-AU browser reads kilometres.
- No date pattern or am/pm is written by hand. Formatting stays in
@/lib/time, and the Schedule-X mapping stays insrc/lib/shape/calendar.ts.
Verification checklist
-
pnpm lint && pnpm typecheck && pnpm test:runpass, including the new cases insrc/lib/time.test.ts,src/lib/shape/calendar.test.tsandsrc/lib/distance.test.ts. -
pnpm dev, browser language pt-BR, time zone Europe/London:/gb/south-east/london/1817reads "Every Friday · 17:45–18:45" and a next-session date like "Fri 27 Nov". - Same page with browser language en-AU: the time reads "5:45 – 6:45 pm".
/calendar?region=gbshows the same 12-hour clock in the grid. -
/calendar?region=gbwith browser language zh-CN: the grid shows 24-hour times and month-first dates, matching the lists. - Browser language en-GB, then en-US: the class page and the calendar read exactly as before this change ("17:45–18:45" and "5:45 – 6:45 PM").
Notes
Blocked by: #509
- Follow-up to feat(dates): every date and time through one Intl formatter, in the visitor's own format #509, which introduced
regionalLocale,formatLocaleand the region-following calendar grid. These two gaps were left out of that PR on purpose and are listed in its body. - The measurements come from Node 26 / ICU. Browsers ship their own CLDR, so the fix must detect a dropped region at runtime, not keep a list of regions.
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
Low
Hold Until
None yet
Projects
- StatusShow more project fieldsAwaiting
Activity