JavaScript's native date API is rather weak.
Actually, the Date() object has been a long-standing pain point in ECMAScript.
It comes from ideas taken from the java.util.Date (sic!) package,
which became obsolete back in 1997!
It has many limitations - just to name a few:
- it only supports UTC and the user’s PC time,
- it doesn’t support non-Gregorian calendars,
- string to date parsing is error-prone,
- Date objects are mutable
It is possible to use external libraries, but it's an additional payload
which is not always desirable, and is non-standard.
But there's good news!
New Temporal static global date object,
that acts as a top-level namespace (like Math),
is at Stage 3 Candidate Proposal in the TC39 standards approval process
(the final stage before implementation).
The Temporal fixes these above-mentioned Date() problems by:
- Providing easy-to-use APIs for date and time computations
- First-class support for all time zones, including DST-safe arithmetic
- Dealing only with objects representing fixed dates and times
- Parsing a strictly specified string format
- Supporting non-Gregorian calendars
- etc...
This makes code more readable and prevents bugs caused by incorrectly assuming
0, UTC, or the local time zone for values that are actually unknown.
programming geek; accounting professional
In the beginning there was electronics... Tadeusz Kurpiel still shows signs of burns made with a soldering iron in the early '80s. Then it was the 1st useful program written in ZX Spectrum Basic, calculating the parameters of the Tchebyschew Filters for the school ham radio club. And the dos-resident (working in the background) program supporting the design of electronic circuits in the OrcadPCB environment. In the '90s Tadeusz started using the web before the present web even existed - in the days of gopher, telnet and ftp. Later, he worked with time and dates for many years... calculating the tax interest rates and other similar things. In his spare time he deals with genealogy, where the issue of the dates and various date formats and calendars is important. That's why the Temporal is the topic he wants to present.
View Full Profile