top of page
Search

Reinventing Time: The Future of Calendars, Time Zones, and JavaScript’s Temporal API

  • Writer: Aditya Jadoun
    Aditya Jadoun
  • Mar 17, 2022
  • 2 min read

It's about time we had a real talk about time—a concept that seems straightforward but is actually tangled up in various complications. Let's start with the basics: Unix time began on January 1, 1970. This epoch is a standard for tracking time in milliseconds on computers using methods like Date.now(), a concept known as incremental time.


But the Earth's rotation isn't perfectly consistent, and believe it or not, it's actually flat (just kidding). The International Earth Rotation Service occasionally mandates a leap second to adjust for these inconsistencies, adding a second to the last minute of the day. Then, we dive into the chaos of time zones, calculated relative to Greenwich Mean Time (GMT). For example, Pacific Time subtracts eight hours, while Newfoundland subtracts three and a half, and Nepal adds five and three quarters. When daylight saving time (DST) kicks in, time zones shift, except in places like Arizona and Hawaii that don’t observe DST. In the South Pacific, they skip an entire day by being 13 hours ahead.


You could theoretically celebrate New Year's twice by hopping between Christmas Island and Jarvis Island, thanks to the International Date Line. Our Gregorian calendar, a mess of 28 to 31-day months, doesn't help. The Cotsworth Plan from 1902 proposed a more logical 13-month calendar with consistent 28-day months, better aligning with lunar cycles and simplifying date calculations for developers.


There’s a bill in Congress to abolish daylight saving time, a small step toward simplifying our timekeeping but still not enough. Imagine getting rid of the Gregorian calendar altogether—radical, yet it would certainly shake things up for those low-level systems programmers who manage time zone rules, a task no one envies. If DST is abolished, someone will need to rework these time-related systems.


In the realm of JavaScript, the Temporal API, now at stage 3, promises to revolutionize date and time handling. JavaScript’s current date implementation, dating back to 1995 and hastily created by Brendan Eich in 10 days, is widely loathed. Even Java overhauled its API in 1997, but JavaScript still suffers from its outdated system. Libraries like Moment.js and Date-fns help, but an improved built-in solution would be ideal.


The Temporal API aims to address this, providing support for not just milliseconds, but also microseconds and nanoseconds. It introduces time zone-aware objects, simplifying time zone computations and making date manipulation more intuitive. This would be a significant leap forward, easing the burden on developers and providing a more robust and versatile toolset for working with dates and times in JavaScript.

 
 
 

Comments


bottom of page