[GH-ISSUE #2372] [Issue]: Roleplay World tile drops AM/PM on spaced 12-hour times (24-hour regex tried before meridiem) #1172

Closed
opened 2026-10-21 05:28:18 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2372

Originally assigned to: @Romuromylus on GitHub.

Summary

Severity: Low — correctness (regression vs main). In the roleplay tracker World tile, getWorldTimeDisplay runs the 24-hour regex before the meridiem regex, so a 12-hour time with a space before AM/PM (e.g. 6:00 PM) matches the 24-hour pattern and the AM/PM label is dropped. The tile shows a bare 06:00 for an evening time. Main tries the meridiem regex first and renders 06:00 PM.

Expected behavior

6:00 PM should display as 06:00 PM (hour 18, meridiem suffix shown), matching main. Times that include AM/PM should keep their meridiem label.

Actual behavior

src/features/runtime/world-state/lib/world-state-display.ts:177-211 tries the 24-hour regex first (line 181) and only falls back to meridiem (line 194):

// 24-hour tried FIRST
const twentyFourHour = text.match(/\b([01]?\d|2[0-3])[:.h]([0-5]\d)\b/i);
if (twentyFourHour) { /* ... */ return { /* ... */ suffix: "", hour, minute }; }
const meridiem = text.match(/\b(1[0-2]|0?\d)(?::([0-5]\d))?\s*([ap])\.?m?\.?\b/i);
if (meridiem) { /* ... */ }

For 6:00 PM the trailing space is a word boundary, so \b([01]?\d|2[0-3])[:.h]([0-5]\d)\b matches the 6:00 portion and the PM is silently dropped → { hour: 6, suffix: "" }. Same inversion for 3:30 PM, 8:15 am, 6:00 p.m.. (6:00pm with no space parses correctly on both branches, because the missing word boundary makes the 24h regex miss.)

Consumed in roleplay via RoleplayHUDWorldWidget.tsx:61 and the expanded WorldStatePanel Time tile (WorldDateTimeTiles.tsx:100,113-122). WorldDateTimeTiles.tsx:119-122 only renders display.suffix when present, so an evening 6:00 PM shows a bare 06:00 with no PM badge — it reads as morning.

Scope correction (so this is not over-stated): the analog clock face is not wrong. Both WorldClockFace (WorldDateTimeTiles.tsx:70) and the HUD widget (RoleplayHUDWorldWidget.tsx:64) compute the hand angle from hour % 12, so hour 6 and hour 18 produce the same hand position. The only user-visible loss is the dropped AM/PM label on the numeric time. Numeric time and editability are preserved.

Steps to reproduce

  1. Be in a roleplay-mode chat where the world-state tracker emits a time like 6:00 PM or 3:30 PM (colon + space + AM/PM — the form LLMs overwhelmingly produce).
  2. Open the tracker World tile / HUD world widget.
  3. Observe the time shows without the AM/PM suffix (e.g. 06:00 for an evening time).

Impact area

  • Roleplay mode
  • Runtime systems: generation, world-state, visuals, tracker, or haptics

Environment

  • Branch or commit: refactor @ 330f69a8
  • Run mode: Tauri desktop (applies to both desktop and web shell)
  • OS + version: not relevant (static source audit, empirically reproduced by running both regexes)
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: any model emitting H:MM AM/PM times

Logs, screenshots, or video

Static source audit. Reproduced by running both regexes side by side: refactor 6:00 pm → { path: 24h, hour: 6, suffix: "" } vs main { path: meridiem, hour: 18, suffix: "PM" }.

Regression notes

Regression vs main — worked on main, broken on refactor. Main's getWorldTimeDisplay (packages/client/src/features/tracker-panel/lib/world-state-display.ts:209) tries the meridiem regex first and the 24-hour regex second (:224), so 6:00 pm → hour 18, suffix PM.

Additional context

Fix sketch: run the meridiem match before the 24-hour match (as main does), or add a negative lookahead to the 24h regex so it does not consume an H:MM immediately followed by optional whitespace + a/p/m, e.g. ...([0-5]\d)\b(?!\s*[ap]\.?m?\.?\b). Keep the refactor-only additions (the [:.h] separator support and the keyword-hour fallback); only the branch ordering needs to change.

No open issue covers time-string parse ordering. Not a duplicate of #2317 / #2327 / #2294.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2372 Originally assigned to: @Romuromylus on GitHub. ## Summary **Severity: Low — correctness (regression vs main).** In the roleplay tracker World tile, `getWorldTimeDisplay` runs the 24-hour regex before the meridiem regex, so a 12-hour time with a space before AM/PM (e.g. `6:00 PM`) matches the 24-hour pattern and the AM/PM label is dropped. The tile shows a bare `06:00` for an evening time. Main tries the meridiem regex first and renders `06:00 PM`. ## Expected behavior `6:00 PM` should display as `06:00 PM` (hour 18, meridiem suffix shown), matching main. Times that include AM/PM should keep their meridiem label. ## Actual behavior `src/features/runtime/world-state/lib/world-state-display.ts:177-211` tries the 24-hour regex first (line 181) and only falls back to meridiem (line 194): ```ts // 24-hour tried FIRST const twentyFourHour = text.match(/\b([01]?\d|2[0-3])[:.h]([0-5]\d)\b/i); if (twentyFourHour) { /* ... */ return { /* ... */ suffix: "", hour, minute }; } const meridiem = text.match(/\b(1[0-2]|0?\d)(?::([0-5]\d))?\s*([ap])\.?m?\.?\b/i); if (meridiem) { /* ... */ } ``` For `6:00 PM` the trailing space is a word boundary, so `\b([01]?\d|2[0-3])[:.h]([0-5]\d)\b` matches the `6:00` portion and the `PM` is silently dropped → `{ hour: 6, suffix: "" }`. Same inversion for `3:30 PM`, `8:15 am`, `6:00 p.m.`. (`6:00pm` with no space parses correctly on both branches, because the missing word boundary makes the 24h regex miss.) Consumed in roleplay via `RoleplayHUDWorldWidget.tsx:61` and the expanded `WorldStatePanel` Time tile (`WorldDateTimeTiles.tsx:100,113-122`). `WorldDateTimeTiles.tsx:119-122` only renders `display.suffix` when present, so an evening `6:00 PM` shows a bare `06:00` with no PM badge — it reads as morning. Scope correction (so this is not over-stated): the analog clock face is **not** wrong. Both `WorldClockFace` (`WorldDateTimeTiles.tsx:70`) and the HUD widget (`RoleplayHUDWorldWidget.tsx:64`) compute the hand angle from `hour % 12`, so hour 6 and hour 18 produce the same hand position. The only user-visible loss is the dropped AM/PM label on the numeric time. Numeric time and editability are preserved. ## Steps to reproduce 1. Be in a roleplay-mode chat where the world-state tracker emits a time like `6:00 PM` or `3:30 PM` (colon + space + AM/PM — the form LLMs overwhelmingly produce). 2. Open the tracker World tile / HUD world widget. 3. Observe the time shows without the AM/PM suffix (e.g. `06:00` for an evening time). ## Impact area - [x] Roleplay mode - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics ## Environment - Branch or commit: refactor @ 330f69a8 - Run mode: Tauri desktop (applies to both desktop and web shell) - OS + version: not relevant (static source audit, empirically reproduced by running both regexes) - Node + pnpm versions: not relevant - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: any model emitting `H:MM AM/PM` times ## Logs, screenshots, or video Static source audit. Reproduced by running both regexes side by side: refactor `6:00 pm` → `{ path: 24h, hour: 6, suffix: "" }` vs main `{ path: meridiem, hour: 18, suffix: "PM" }`. ## Regression notes Regression vs main — worked on main, broken on refactor. Main's `getWorldTimeDisplay` (`packages/client/src/features/tracker-panel/lib/world-state-display.ts:209`) tries the meridiem regex first and the 24-hour regex second (`:224`), so `6:00 pm` → hour 18, suffix `PM`. ## Additional context Fix sketch: run the meridiem match before the 24-hour match (as main does), or add a negative lookahead to the 24h regex so it does not consume an `H:MM` immediately followed by optional whitespace + `a/p/m`, e.g. `...([0-5]\d)\b(?!\s*[ap]\.?m?\.?\b)`. Keep the refactor-only additions (the `[:.h]` separator support and the keyword-hour fallback); only the branch ordering needs to change. No open issue covers time-string parse ordering. Not a duplicate of #2317 / #2327 / #2294. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:18 +07:00
Author
Owner

@Romuromylus commented on GitHub (Jun 6, 2026):

Fixed by #2381, merged into refactor (squash 54c12e71).

<!-- gh-comment-id:4637085809 --> @Romuromylus commented on GitHub (Jun 6, 2026): Fixed by #2381, merged into `refactor` (squash 54c12e71).
Sign in to join this conversation.
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
Pasta-Devs/Marinara-Engine#1172
No description provided.