Live data from Hacker News

Temporal: The 9-year journey to fix time in JavaScript

bloomberg.github.io

211–220 of 284 posts

Re: Temporal: The 9-year journey to fix time in JavaScript

#211

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();

What you want there is to stop saying "day" and instead say "24 hours." This way the code is correct and you don't need to deal with time weirdness.

Re: Temporal: The 9-year journey to fix time in JavaScript

#213

My 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

"Just use UTC" is another, albeit more subtle, falsehood programmers believe about date/time.

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

#214

Noticed 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

I think this is intentional design. Anyway we can convert `Temporal.PlainDate` to other calendars explicitly (I believe explicitness is good here).

  today.withCalendar('hebrew').toLocaleString("en", { calendar: "hebrew" });
  // "22 Adar 6329"

Re: Temporal: The 9-year journey to fix time in JavaScript

#215
post #57

> 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.

An example that is hard to follow defeats the point. It's just showing what pattern is possible and you can imagine the abstraction layers and indirection that would make it happen accidentally.

Re: Temporal: The 9-year journey to fix time in JavaScript

#217
Temporal is a good idea, but the API is too complicated for broad adoption:

- 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…

The biggest problem with IE from a developer standpoint wasn't the slow feature release cadence, it was that the features it did have worked differently from standards-based browsers. That's very much the position of Safari/WebKit today - code that works across all other engines throws errors in WebKit and often requires substantial changes to resolve.

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.

Post reply on HN