The Temporal date time API is accessible via the global variable
Temporal. It is a pleasure to use:
- All objects are immutable. Changing them produces new values, similarly to how strings work in JS.
- There is support for time zones and non-Gregorian calendars.
- There are several specialized classes for Temporal values (date time values with time zones, date time values without time zones, date values without time zones, etc.). That has several benefits:
- The context of a value (time zone or not, etc.) is easier to understand.
- It is often more obvious how to achieve a given task.
.toString()can be used with much less consideration.
- January is month 1.
(The Temporal proposal is currently at Stage 3. The API isn’t expected to change and is being implemented.)
Sign in or Join to comment or subscribe