news.volyx.in

JavaScript dates are about to be fixed (docs.timetime.in)

413 points by thunderbong · 715 days ago · 277 comments on HN

Article summary

The Temporal API is a new proposal for handling dates and times in JavaScript, aiming to solve the issues with the current Date object. It introduces a ZonedDateTime object that can accurately represent dates and times with their corresponding time zone. This new API is designed to handle time zones and daylight saving time (DST) correctly, making it easier to work with dates and times in JavaScript. The proposal is currently at stage 3 and has production-ready polyfills available.

Main themes

  • Temporal API
  • Date and Time Handling
  • Time Zones
  • Daylight Saving Time
  • JavaScript Development

What commenters say

  • Using UTC timestamps alone is not enough to accurately represent dates and times, as it can lead to confusion when dealing with time zones and DST.
  • Storing time zones and timestamps separately can be a viable solution, but it may not cover all edge cases, such as changes in time zone policies.
  • Some argue that using UTC timestamps and converting them to local time for display is the best approach, while others believe that storing local time and converting it to UTC can be more convenient.
  • The use of external libraries or polyfills can help mitigate the issues with the current Date object, but a native solution like the Temporal API is still necessary.
  • The complexity of time zones and DST rules makes it challenging to develop a foolproof system, and different approaches may be needed for different use cases.
  • Some commenters suggest that using a more fundamental time standard, such as TAI, could help simplify time handling, but it may not be practical for all applications.