Skip to content

UTC offset on a date-time literal is ignored: 14:30+02:00 is read as 14:30Z #27

Open

Description

@aurelleb

A UTC offset written on a date-time literal is ignored when the instant is computed. The clock time is read as UTC and the offset is then only used to display it. So 14:30+02:00 comes out as 16:30 instead of 14:30.

Verified on main @ 42dcb73. The host zone was frozen to UTC, and Europe/Paris gives the same instants:

Input numen Expected
2026-01-18T14:30:00Z to epoch 1,768,746,600 1,768,746,600 ✓
2026-01-18T14:30:00+02:00 16:30:00 (Etc/UTC+2) 14:30:00 (Etc/UTC+2)
2026-01-18T14:30:00+02:00 to epoch 1,768,746,600 (= 14:30Z) 1,768,739,400 (= 12:30Z)
2026-01-18 14:30 utc+2 to epoch 1,768,746,600 1,768,739,400
2026-01-18 14:30 utc-5 to epoch 1,768,746,600 1,768,764,600

Under RFC 3339, 14:30:00+02:00 is 12:30Z. Named zones on a literal already behave correctly: 2026-01-18 14:30 cest to epoch gives 1,768,743,000, i.e. 14:30 wall-clock in Paris. Offsets used as a conversion target are also fine: now to utc+9 gives 09:00 for a midnight-UTC "now".

Likely cause: src/numen/datetime.cpp:142-145. The instant is computed in the base zone, and d.timezone->offset is only copied into DateTime::offset for display. It is never subtracted from the instant.

Tests that assert the current behaviour and would change: tests/corpus/datetime.corpus lines 72, 73, 78 and 79.

Related: draft PR #23 (for #15) extends parseRFC3339 and keeps the current offset semantics. Whichever lands second will need its expected values adjusted.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions