Summary
The new ECMAScript API is so incredible that I will likely dedicate several blog posts to highlighting its key features. I will focus on explaining one of its main advantages: we finally have a native object to represent a "Zoned Date Time"
Since my browser is on an CET timezone, when I write this the browser just "computes the number of milliseconds since the EPOX given this CET instant" This is what we actually store in a date. Many people might be tempted to do something like this:const paymentDate = new Date('2024-07-20T10:30:00');
In this week's edition of The Daily Discussion, we look at some of the most important issues of the day. This week's topic is the topic of the week: The Internet.
Temporal API offers a significant advantage when creating dates. One of the standout features is its ability to effortlessly handle time zones. This precision means that your date will always reflect the correct moment in time.
Adding or subtracting the time portion of a duration should ignore DST transitions. The result will automatically adjust for Daylight Saving Time using the rules of this instance's timeZone field.
This might look like an obvious operation but I encourage you to read the full spec to understand the nuances of it. If other is earlier than zonedDateTime then the resulting duration will be negative. If using the default options, adding the returned Temporal.Duration to zoned date will yield other.