Exploring the JavaScript Temporal API - Supported in Firefox 139.0 (kcode.de)
from Kissaki@programming.dev to programming@programming.dev on 28 May 21:07
https://programming.dev/post/31210151

cross-posted from: programming.dev/post/31210046

Firefox 139.0 released yesterday, with support for the Temporal JavaScript API.

I explored the API, writing down the most relevant interfaces into a reference or cheat sheet.

It’s certainly and finally a thorough API for handling temporal information. Working with zoned datetime across time offsets and time zones can get very confusing, though.

I love how you can work with them though, especially with durations.

console.log(Temporal.PlainDateTime.from('2025-02-05T08:00:00'))

console.log(Temporal.Now.plainDateTimeISO("Europe/Berlin"))

console.log(Temporal.Now.plainDateTimeISO().add('PT2M0.2S').subtract('PT0.5S').since(Temporal.Now.plainDateTimeISO()))

console.log(Temporal.ZonedDateTime.from('2025-02-05T13:57:35.777888[Europe/Berlin]').withTimeZone('Europe/London'))

#programming

threaded - newest