Skip to content

chains: recognise plain UTC as a timezone in proposed spans - #24

Merged
wfzyx merged 1 commit into
wfzyx:masterfrom
kevin9327:fix/plain-utc-zone
Oct 7, 2026
Merged

wfzyx merged 1 commit into
wfzyx:masterfrom
kevin9327:fix/plain-utc-zone

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

chains/spans.py matches named zones with [A-Z]{2,4}T\b, which covers GMT, CEST, EST and the rest, plus utc±N for offsets. Plain UTC doesn't end in T, so it never matches, even though ZONES maps "utc": 0.

>>> propose("The call is on 3 September 2026 at 14:00 UTC.")
[Span(kind='datetime', text='3 September 2026 at 14:00', ..., meta={'zone': None, ...})]
>>> propose("The call is on 3 September 2026 at 14:00 GMT.")   # GMT works
[Span(kind='datetime', text='3 September 2026 at 14:00 GMT', ..., meta={'zone': {'offset_h': 0}, ...}),
 Span(kind='timezone', text='GMT', value={'offset_h': 0}, ...)]

So a UTC time stays naive: it ranks last for prefer="with_zone" slots, no timezone span is offered, and ops can't place it against zoned times.

Change: add utc\b to _ZONE_RE, after the utc±N alternative so UTC+2 still matches whole.

Test: test_propose_plain_utc_is_a_zone covers a plain-UTC datetime next to a UTC+2 one (zones, span text, and timezone spans). It fails on main and passes with this change.

uv run pytest -q tests/test_chains.py   # 25 passed

I also ran the other test files one at a time (backends, calibrate, clef_head, device, fanout, jevcompat_issue16, noul_band, patterns_presets, server, train_write_json, version_lockstep), and they all pass. test_client, test_openjev_compatibility and test_primitives didn't finish on this machine within the time limit, and none of them import chains.

@wfzyx
wfzyx merged commit 0e65bb5 into wfzyx:master Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants