feat: Add optional temporal support#73
Merged
Merged
Conversation
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
force-pushed
the
mkt/temporal-support
branch
from
July 13, 2026 22:46
a4390e6 to
977b297
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds optional Temporal support for several TOML types:
Temporal.ZonedDateTimeTemporal.PlainDateTimeTemporal.PlainDateTemporal.PlainTimeOpt-in is via
useTemporal: truein the options toparse; an optionaltemporalkey can specify a Temporal implementation for runtimes that don't have one.Closes #69