Skip to content

feat: Add optional temporal support#73

Merged
BinaryMuse merged 2 commits into
masterfrom
mkt/temporal-support
Jul 13, 2026
Merged

feat: Add optional temporal support#73
BinaryMuse merged 2 commits into
masterfrom
mkt/temporal-support

Conversation

@BinaryMuse

@BinaryMuse BinaryMuse commented Jul 13, 2026

Copy link
Copy Markdown
Owner

This PR adds optional Temporal support for several TOML types:

TOML Temporal
Offset Date-Time Temporal.ZonedDateTime
Local Date-Time Temporal.PlainDateTime
Local Date Temporal.PlainDate
Local Time Temporal.PlainTime

Opt-in is via useTemporal: true in the options to parse; an optional temporal key can specify a Temporal implementation for runtimes that don't have one.

Closes #69

claude and others added 2 commits July 8, 2026 03:44
Add an optional second argument to toml.parse(). When useTemporal is
set, date/time values are returned as their Temporal counterparts
instead of the default representations:

- Offset date-time -> Temporal.ZonedDateTime (was Date)
- Local date-time  -> Temporal.PlainDateTime (was string)
- Local date       -> Temporal.PlainDate (was string)
- Local time       -> Temporal.PlainTime (was string)

Offset date-times keep the offset written in the document as the
ZonedDateTime's time zone (Z maps to UTC), which the default Date
representation cannot preserve. Fractional seconds beyond nanosecond
precision are truncated, as permitted by the TOML spec.

Runtimes without a global Temporal can supply an implementation
(e.g. @js-temporal/polyfill) via the new `temporal` option; asking
for useTemporal with no implementation available throws a
descriptive error. Default (option-less) behavior is unchanged.

Fixes #69

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019m453gv37rxPBWFRDC5MiW
Master released 4.2.0 with the nesting-depth DoS fix, which also
introduced a parse(input, options) signature for its maxDepth option.
Resolved by combining both features on the shared options object:
parser.parse receives options (maxDepth), compiler.compile receives
options (useTemporal/temporal), and ParseOptions in index.d.ts now
declares all three. The Temporal changelog entry moves to 4.3.0 since
4.2.0 is taken. lib/parser.js regenerated from the merged grammar.
@BinaryMuse
BinaryMuse force-pushed the mkt/temporal-support branch from a4390e6 to 977b297 Compare July 13, 2026 22:46
@BinaryMuse
BinaryMuse merged commit 5222a64 into master Jul 13, 2026
3 checks passed
@BinaryMuse
BinaryMuse deleted the mkt/temporal-support branch July 13, 2026 22:48
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.

Parse date/time values to Temporal

2 participants