Repository navigation
Conversation
Temporal objects previously crossed the boundary as empty dicts (their data lives in internal slots invisible to generic object conversion). They now convert via tagged payloads, following the existing Date/Set bridge pattern across all four boundary paths (eval results, function call args, op args, op return values): Temporal.Instant <-> aware datetime (UTC; sub-us truncated) Temporal.ZonedDateTime <-> aware datetime (ZoneInfo / fixed offset) Temporal.PlainDate <-> date (non-ISO calendars normalized) Temporal.PlainTime <-> time Temporal.PlainDateTime <-> naive datetime Temporal.Duration <-> timedelta Python date, time, and timedelta previously raised 'Unsupported Python type'; they now convert to the matching Temporal instances. datetime keeps converting to a JS Date for backwards compatibility. Durations with nonzero years/months/weeks are calendar-relative and stay unconverted. 21 new tests; docs in concepts/types.md.
Review findings on the Temporal conversion: - Duration: drop the i64 narrowing of total microseconds; i128 converts to an arbitrary-precision Python int and timedelta's constructor enforces its own range, so timedelta.max-scale durations round-trip. - ZonedDateTime/Instant: build the local wall-clock fields with integer math (offset probe + date.fromordinal) instead of materializing the intermediate UTC datetime, which rejected instants whose local form is valid but whose UTC form falls outside years 1-9999. Ambiguous DST fall-back wall times get fold=1 when that occurrence matches the instant's actual offset.
Owner
Author
|
Addressed both review findings (44ca27e):
3 new tests; 324 total passing, lint clean. |
This branch has not been deployed
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.
Why
The V8 15 upgrade (#10) shipped a mature, Rust-backed
Temporalimplementation — but any Temporal value crossing into Python arrived as an empty dict{}(its data lives in internal slots, invisible to generic object conversion). Meanwhile Pythondate/time/timedeltaraisedUnsupported Python type. This closes both gaps using the package's existing typed-conversion identity.Mechanism
Temporal values travel as tagged payloads, the same pattern
Date/Set/BigIntalready use, across all four boundary paths:Blast radius
ops.rsbridgetemporalPrepare/temporalRevivehelpers (also exposed as globals for the Rust paths); one hook inprepare(), one case inrevive()runner.rsjs_value_to_v8upgrades tagged payloads via the helperconversion.rsTemporaltag → Python types; newdate/time/timedeltabranches (previously an error, so purely additive)datetimebehaviorDate(back-compat)Durationwith nonzero years/months/weeks (calendar-relative, no fixed length); awaretimeraises a clear errorValidation
tests/test_temporal.py: all six types both directions, ops path, IANA + offset time zones, non-ISO calendars, negative epochs/durations, nesting, round-trips, back-compat.make lintclean.