Created
May 28, 2025 05:52
-
-
Save robinpokorny/e01eaa88202886d4a00350346ec27a4f to your computer and use it in GitHub Desktop.
Temporal API example for WebExpo talk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const talkStart = Temporal.ZonedDateTime.from({ | |
timeZone: `Europe/Prague`, | |
year: 2025, | |
month: 5, | |
day: 28, | |
hour: 2, | |
minute: 20, | |
}) | |
console.assert(talkStart.toString() === `2025-05-28T02:20:00+02:00[Europe/Prague]`) | |
console.assert(talkStart.toInstant().toString() === `2025-05-28T00:20:00Z`) | |
console.assert( | |
talkStart.withTimeZone("America/Los_Angeles").toString() === | |
`2025-05-27T17:20:00-07:00[America/Los_Angeles]`, | |
) | |
const talkEnd = talkStart.add({ minutes: 20 }) | |
console.assert(talkEnd.toString() === `2025-05-28T02:40:00+02:00[Europe/Prague]`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment