Author Information
Brian Kardell
  • Developer Advocate at Igalia
  • Original Co-author/Co-signer of The Extensible Web Manifesto
  • Co-Founder/Chair, W3C Extensible Web CG
  • Member, W3C (OpenJS Foundation)
  • Co-author of HitchJS
  • Blogger
  • Art, Science & History Lover
  • Standards Geek
Follow Me On...
Posted on 04/30/2021

ES Temporal: 2 Minute Standards

You might have heard that Temporal has recently reached Stage 3 in ECMA, here's a #StandardsIn2Min explaination of it...

Since it's beginnings JavaScript has had only a rudimentary Date object. It copied Date from an early edition of Java and it was intended to be used for programming just about anything relating to time. While Java itself quickly deprecated and improved their situation, JavaScript implementations didn't follow suit. It also introduced its own warts and quirks to Date along the way. As a result, JavaScript libraries dedicated toward reasoning about the complexities of time, like moment.js became common and essential.

Temporal, now at stage 3 as of this writing, is the result of a lot of work initiated by maintainers of those projects and shepherded through the standards process. It introduces lots of rich APIs to the JavaScript standard library, hosted by a new top-level Temporal object. Large top-level introductions of this sort (like Temporal, Math and Intl) are exceedingly rare.

Temporal provides a number of objects, all immutable and serializable, and each with their own methods for reasoning about time in different ways.

It contains some fundamental concepts which implement standards for calendar systems and timezones respectively, and set the foundations for how a lot of methods do their work:

It introduces Temporal.Instant which is used for dealing with an instant in time to various degrees of precision.

It also introduces a number of "plain" themed objects geared toward providing APIs for the different ways we think about time not simply in terms of different kinds of precision. For example...

It also includes...

A diagram illustrating the different types, relationships and concepts described that make up Temporal

You can learn a lot more by following through links in the Temporal proposal repo, including helpful Reference documentation and examples, a cookbook to help you get started and learn the ins and outs of Temporal which include a (not production ready) polyfill in every page so that you can open Dev Tools and explore for yourself.

If you're interested in hearing about the history, development, challenges, inner workings or rationale behind any of this, I recently hosted an edition of our podcast on this topic with guests who worked on the standard.