I try to use Temporal in Chrome, but it fails:
Temporal.DateTime.from("2019-11-26T14:58:54.147Z")
Uncaught ReferenceError: Temporal is not defined at :1:1
Version: Chromium 78.0.3904.108
How to use Temporal in Chrome?
BTW. Above question is solved, but ...
But I want more. I don't want to parse strings and convert them to an object over and over again. I want to parse a JSON string and get nice high level DateTime objects immediately.
Source: .md#add-datetime
I try to use Temporal in Chrome, but it fails:
Temporal.DateTime.from("2019-11-26T14:58:54.147Z")
Uncaught ReferenceError: Temporal is not defined at :1:1
Version: Chromium 78.0.3904.108
How to use Temporal in Chrome?
BTW. Above question is solved, but ...
But I want more. I don't want to parse strings and convert them to an object over and over again. I want to parse a JSON string and get nice high level DateTime objects immediately.
Source: https://github./guettli/lets-fix-json/blob/master/README.md#add-datetime
Share Improve this question edited Jun 9, 2022 at 19:29 Justin Grant 46.8k16 gold badges132 silver badges222 bronze badges asked Nov 26, 2019 at 15:39 guettliguettli 27.2k105 gold badges413 silver badges758 bronze badges2 Answers
Reset to default 7When the question was asked, Temporal was a Stage 2 proposal, so it wasn't surprising if Chrome's V8 didn't have it at that time. (It certainly wouldn't be unflagged.)
Typically JavaScript engines don't implement proposals until Stage 3 (that's part of what Stage 3 is for — more about the stages here). Usually they're behind a flag initially, the eventually unflagged once they've been sufficiently field-tested, but Temporal is a special case; from the explainer linked above (their emphasis):
NOTE: Although this proposal's API is not expected to change, implementers of this proposal MUST NOT ship unflagged Temporal implementations until IETF standardizes timezone/calendar string serialization formats. See #1450 for updates.
V8 support for temporal is underway as of June 2022; here's the tracking issue for it.
In the meantime, the proposal links to polyfills you can use here.
As of today, Temporal is a Stage 3 propsal.
It is currently not implemented in any browser. The process of implementation is ongoing, at least in Chrome.
There is a polyfill available for experimental usage. It follows closely the existing Temporal spec.