denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.56k stars 5.25k forks source link

Temporal.Now.timeZoneId is not a function #22161

Open NogrTL opened 8 months ago

NogrTL commented 8 months ago

Version: Deno 1.40.2

Problem

Temporal.Now.timeZoneId(); is not a function. Spec: https://tc39.es/proposal-temporal/docs/now.html#timeZoneId

Example Code

id = Temporal.Now.timeZoneId();
now = Temporal.Now.instant();
tz = Temporal.TimeZone.from(id);
nextTransition = tz.getNextTransition(now);
before = tz.getOffsetStringFor(nextTransition.subtract({ nanoseconds: 1 }));
after = tz.getOffsetStringFor(nextTransition.add({ nanoseconds: 1 }));
console.log(
  `At ${nextTransition.toZonedDateTimeISO(
    id
  )} the offset will change from UTC ${before} to ${after}`
);

Error

error: Uncaught (in promise) TypeError: Temporal.Now.timeZoneId is not a function
id = Temporal.Now.timeZoneId();
                  ^
    at file:///C:/Users/Nogr/Personal%20Projects/Web/temporal-api/3_timeZoneId.js:1:19
bartlomieju commented 8 months ago

We need to wait for V8 to support this API.

pihentagy commented 8 months ago

I don't know how is that related, but anyway, there is a function named timeZone.

Deno 1.40.2
> Temporal.Now.timeZone()
Europe/Budapest
0f-0b commented 2 weeks ago

25505 added a polyfill for this function.