Event dates in UK order; latest same-day news story first #34

Merged
iec-admin merged 1 commit from claw/event-dates-uk-6a1f into main 2026-10-12 22:56:51 +00:00
Contributor

Closes #33.

What changed

  • Event dates in UK order. Editors type date labels US-style ("May 13, 2026 – May 14, 2026"). displayEventDate() in src/lib/event-order.ts shows them as "13 – 14 May 2026" on the events list, the event page and its "other events" tiles. A label it cannot read ("Date TBC", "Autumn 2026", "Mid-October 2026") is shown exactly as typed. Stored labels are not rewritten.
  • Event sorting uses the same parser instead of Date.parse, so a range with the year only on its end ("October 11 - October 14, 2026") and a compact range ("May 13-14, 2026") sort by their start date.
  • Events admin has a UK-style placeholder and a "Visitors see: …" preview under the date label.
  • News ordering. One shared NEWS_SORT (date desc, then createdAt desc, then order) is used by the public loader, the admin page and the admin API, so stories dated the same day list the most recently added first.

Walkthrough

Story: as a site visitor, I read event dates written the British way.

Driven in a browser (Playwright) against npm run dev on this branch, with the local database, whose stored labels are US-style:

Screen Stored label Shown
/events May 13, 2026 – May 14, 2026 13 – 14 May 2026 | Exhibition
/events June 23, 2026 23 June 2026 | Conference
/events August 2026 August 2026 | Briefing
/events September 28, 2026 – October 1, 2026 28 September – 1 October 2026 | Conference
/events/biba-conference-2026 (When rail) 13 – 14 May 2026; tiles 23 June 2026, August 2026, 28 September – 1 October 2026
/admin/events each of the four "Visitors see: …" matches the public page; placeholder 13 – 14 May 2026 on all four date fields
/admin/news, /news both load (200), newest story first

Reference: UK date order (day month year, en dash for ranges) as used on gov.uk and by UK insurance market sites; no accounting or reference-system behaviour is involved.

QA Execution

2026-10-12, local:

  • npx tsc --noEmit — exit 0
  • npm run build — exit 0
  • Parser run over 19 labels, including: October 11 - 14, 2026 → 11 – 14 October 2026; December 30, 2026 – January 2, 2027 → 30 December 2026 – 2 January 2027; May 13, 2026 – May 13, 2026 → 13 May 2026; Oct. 3, 2026 → 3 October 2026; Date TBC, Autumn 2026, 2026, empty → unchanged and sorted last.
  • Sort check: a startDate of 2026-05-13, August 2026, October 11 - October 14, 2026, Date TBC come out in that order.

Not done in this PR

  • The same-day news tiebreak was not exercised with real data: the local database has no two stories on the same day. The sort itself runs (both news pages load in the right order).
  • No automated tests: the repo has no test runner, so the parser is covered only by the manual run above.
  • An impossible date is not rejected: June 31, 2026 is shown as 31 June 2026.
  • Production event labels were not read (the tawa session had expired), so the table above is from the local database.

🤖 Generated with Claude Code

Closes #33. ## What changed - **Event dates in UK order.** Editors type date labels US-style ("May 13, 2026 – May 14, 2026"). `displayEventDate()` in `src/lib/event-order.ts` shows them as "13 – 14 May 2026" on the events list, the event page and its "other events" tiles. A label it cannot read ("Date TBC", "Autumn 2026", "Mid-October 2026") is shown exactly as typed. Stored labels are not rewritten. - **Event sorting** uses the same parser instead of `Date.parse`, so a range with the year only on its end ("October 11 - October 14, 2026") and a compact range ("May 13-14, 2026") sort by their start date. - **Events admin** has a UK-style placeholder and a "Visitors see: …" preview under the date label. - **News ordering.** One shared `NEWS_SORT` (`date` desc, then `createdAt` desc, then `order`) is used by the public loader, the admin page and the admin API, so stories dated the same day list the most recently added first. ## Walkthrough Story: as a site visitor, I read event dates written the British way. Driven in a browser (Playwright) against `npm run dev` on this branch, with the local database, whose stored labels are US-style: | Screen | Stored label | Shown | |---|---|---| | `/events` | `May 13, 2026 – May 14, 2026` | `13 – 14 May 2026 \| Exhibition` | | `/events` | `June 23, 2026` | `23 June 2026 \| Conference` | | `/events` | `August 2026` | `August 2026 \| Briefing` | | `/events` | `September 28, 2026 – October 1, 2026` | `28 September – 1 October 2026 \| Conference` | | `/events/biba-conference-2026` | (When rail) | `13 – 14 May 2026`; tiles `23 June 2026`, `August 2026`, `28 September – 1 October 2026` | | `/admin/events` | each of the four | "Visitors see: **…**" matches the public page; placeholder `13 – 14 May 2026` on all four date fields | | `/admin/news`, `/news` | | both load (200), newest story first | Reference: UK date order (day month year, en dash for ranges) as used on gov.uk and by UK insurance market sites; no accounting or reference-system behaviour is involved. ## QA Execution 2026-10-12, local: - `npx tsc --noEmit` — exit 0 - `npm run build` — exit 0 - Parser run over 19 labels, including: `October 11 - 14, 2026` → `11 – 14 October 2026`; `December 30, 2026 – January 2, 2027` → `30 December 2026 – 2 January 2027`; `May 13, 2026 – May 13, 2026` → `13 May 2026`; `Oct. 3, 2026` → `3 October 2026`; `Date TBC`, `Autumn 2026`, `2026`, empty → unchanged and sorted last. - Sort check: a `startDate` of 2026-05-13, `August 2026`, `October 11 - October 14, 2026`, `Date TBC` come out in that order. ## Not done in this PR - The same-day news tiebreak was not exercised with real data: the local database has no two stories on the same day. The sort itself runs (both news pages load in the right order). - No automated tests: the repo has no test runner, so the parser is covered only by the manual run above. - An impossible date is not rejected: `June 31, 2026` is shown as `31 June 2026`. - Production event labels were not read (the `tawa` session had expired), so the table above is from the local database. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Event date labels are typed US-style and now shown in UK order on the
events list, the event page and its tiles. Labels that are not dates are
shown as typed. Sorting uses the same parser, so ranges with the year only
on the end, and compact ranges like "May 13-14, 2026", sort correctly.
The events admin previews what visitors will see.

News stories dated the same day fall back to when they were added.

fix #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
martin/ballantyne-www!34
No description provided.