news.volyx.in

JavaScript Temporal is coming (developer.mozilla.org)

1405 points by SigmundurM · 551 days ago · 399 comments on HN

Article summary

The JavaScript Temporal object is a new API for working with dates and times in JavaScript, aiming to simplify and modernize date and time management. It provides support for time zones, calendars, and durations, and is designed to replace the existing Date object. Experimental implementations of Temporal are starting to be shipped in browsers, with Firefox having the most mature implementation so far. The Temporal API has over 200 utility methods and is documented on MDN with over 270 pages of documentation.

Main themes

  • JavaScript Temporal API
  • Date and time management
  • Time zones and calendars
  • Browser support and implementation
  • Replacement for Date object

What commenters say

  • A timezone change event should be added to detect when a user changes time zones, which could be useful for applications that rely on scheduling or time-sensitive data.
  • The client's timezone should only matter to the client and not affect server-side operations, except for translating timestamps into local time for user convenience.
  • Storing dates in UTC and rendering them in the current time zone can be a good approach, but may not work for future events due to potential changes in timezone rules.
  • Adding a timezone change event would not introduce a new data point for fingerprinting, as it is already possible to detect timezone changes by polling certain properties.
  • The operating system is responsible for tracking timezone changes, and the browser should emit a timezone change event on the window when such a change is detected.
  • Some argue that handling timezone changes should be up to the developer to define, rather than having Temporal or the browser impose a specific approach.
  • Others believe that a timezone change event would be useful, but it should not be part of the Temporal API itself, but rather a separate feature of the browser or application environment.