Repository navigation
Support Temporal across Node.js APIs #57891
Description
The Temporal proposal is currently Stage 3, has in progress / experimental implementation in V8 (available in latest releases using --harmony-temporal), and is likely to be unflagged in Node.js once it's stable enough (refs: #57127, #57128).
In light of this, I propose that Node.js begins supporting Temporal in the relevant APIs (mainly those that already work with Dates) after it becomes available by default without runtime flag.
Relevant APIs:
-
fs:StatsandBigIntStats
Only bigint version provides nanosecond precision, and both provide lazy getters forDateinstances. Adding lazy getters forTemporal.Instantwould also make non-bigint version provide nanosecond precision. -
fs:utimes(),lutimes(),futimes(),utimesSync(),lutimesSync(),futimesSync(),promises.utimes(),promises.lutimes(),filehandle.utimes()
Acceptsatimeandmtimeasnumber|string|Date, can supportTemporal.Instantas well.
Note: these functions also don't acceptbigints yet. In the Temporal API,numbers are used forepochTimes in milliseconds whilebigints are used for nanoseconds. Adding direct support ofbigints might result a confusing API: some users might expect it to coerce type and behave exactly the same asnumber|string, some might expect it to be parsed as nanoseconds. AddingTemporalsupport would make it unambiguous.
Maybe there are other APIs that can benefit from this, too?
cc @nodejs/fs since it's only
fs
Internal updates (if it happens to be more precise, more fast, or more readable), generic support (primordials, util, assert, etc.) and dependencies (for example, undici.setCookie(, { expires })) are out of scope here.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsAwaiting Triage
Activity
joyeecheung commentedon Apr 16, 2025
I wonder why util (inspect) and assert support are excluded here. IMO these seem more necessary (have to be implemented by Node.js and are essential for debugging) compared to fs support (which can be worked around by wrapping timestamps).
LiviaMedeiros commentedon Apr 16, 2025
Generic support from
util/assertis out of scope of this issue exactly because there's no questioning that this is necessary and essential. Things like "assert.deepStrictEqual()passes for completely differentTemporal.Instants" (which is currently the case with--harmony-temporal) or "util.inspect(instantInstance)doesn't really inspect its internal datetime value" would be more of a bug once Temporal graduates from experimental state.Specific details that are facing userspace, for example:
...can be discussed, of course.
But this issue is feature requestIssues requesting new Node.js features.
and mainly I'd like to hear the arguments for or against further adoption of Temporal APIs before implementing.
Also it's not limited to
fssubsystem andInstantinstances. Maybe someone would like to have something idiomatic like:Or
Without prior converting it to ms in userspace.
jasnell commentedon Apr 27, 2025
A couple of things here to add to the TODO... Currently there is no C++ API for Temporal in V8. So operations like
IsTemporal...()do not exist. We use c++ level apis to backutil/typeswhich are used internally by the inspect logic. I suspect that we will need that plus something like av8::Temporal::NewInstant(...), etc set of APIs for creating and working with Temporal objects at the native layer.github-actions commentedon Oct 25, 2025
Manishearth commentedon Oct 25, 2025
This is still being worked on in other venues: Milad has an upstream CL that should hopefully unblock node.
ctcpip commentedon Mar 11, 2026
https://bsky.app/profile/tc39.es/post/3mgsa4jzers2x
fs: add `Temporal.Instant` support to `Stats` and `BigIntStats`
fs: add `Temporal.Instant` support to `Stats` and `BigIntStats`
fs: add `Temporal.Instant` support to `Stats` and `BigIntStats`