Earlier quoted context omitted.
Technically, you're not likely to to have to fix a DST bug at 3AM any day but Sunday.
// call foo() one day from now: sleep(86400); foo();
Temporal: The 9-year journey to fix time in JavaScript
211–220 of 284 posts
Re: Temporal: The 9-year journey to fix time in JavaScript
#212Re: Temporal: The 9-year journey to fix time in JavaScript
#213My playbook for JavaScript dates is.. store in UTC.. exchange only in UTC.. convert to locale date time only in the presentation logic. This has worked well for me enough that Im skeptical of needing anything else
It's fine for distributed logging and computer-only usage, but fails in obscure ways once humans, time zones, travel, laws, and/or daylight saving time get involved.
If you're scheduling events for humans, and can't immediately list the reasons your app is an exception to the above, store the time zone to be safe. You probably don't have big data, and nobody will notice the minuscule overhead.
Re: Temporal: The 9-year journey to fix time in JavaScript
#214Noticed that converting between certain calendars is not supported. Was that choice intentional? const today = Temporal.PlainDate.from("2569-03-11[u-ca=buddhist]"); today.toLocaleString("en", { calendar: "hebrew" }); > Uncaught RangeError: calendars "buddhist" and "hebrew" aren't compatible
today.withCalendar('hebrew').toLocaleString("en", { calendar: "hebrew" });
// "22 Adar 6329"Re: Temporal: The 9-year journey to fix time in JavaScript
#215> Developers would often write helper functions that accidently mutated the original Date object in place when they intended to return a new one It's weird that they picked example code that is extremely non -accidentally doing this.
Re: Temporal: The 9-year journey to fix time in JavaScript
#216I wonder if it has a chance to replace chrono and jiff in the rust ecosystem.
Re: Temporal: The 9-year journey to fix time in JavaScript
#217- new Date() equivalent in Temporal is `const now = Temporal.Now.zonedDateTimeISO();`.
- Date.now() equivalent is `Temporal.Now.instant().epochMilliseconds`
- It’s PascalCase, where JS is mostly snakeCase.
- nanoseconds per default. who needs that except Bloomberg? It should have been an option
It’s definitely great all the efforts put in place, but it’s not going to be a replacement to Date which such a complicated design.
Re: Temporal: The 9-year journey to fix time in JavaScript
#218> Safari (Partial Support in Technology Preview) Safari confirmed as IE Spiritual successor in 2020+.
Slower to implement new features, but still implementing them, just makes it the new Firefox. IE's larger problem was how popular it had been before it stopped implementing new features. It was like if Google got bored with Chrome and decided to stop all funding on it. People would be stuck on Chrome for years after that investment stopped because of all the Chrome-specific things built around it (Electron, Puppeteer…
Safari is also pretty popular on iPhones, in fact it has a full 100% market share. With browser updates tied to the OS, that means millions of devices have those "temporary" problems baked in forever.
Re: Temporal: The 9-year journey to fix time in JavaScript
#219Re: Temporal: The 9-year journey to fix time in JavaScript
#220It will take years until this can be widely used as intended.