denoland / deno

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

Non-ISO 8601 calendars don’t work as expected in Temporal #22143

Open mostafah opened 5 months ago

mostafah commented 5 months ago

Version: Deno 1.40.0

TLDR

$ deno --unstable-temporal
> Temporal.Now.zonedDateTime("hebrew").year; // should return 5784
2024
> Temporal.Now.zonedDateTime("hebrew").calendarId; // should not be empty
undefined

Temporal’s proposal includes this example:

dt = Temporal.ZonedDateTime.from('2019-02-23T03:24:30.000003500[Europe/Rome][u-ca=hebrew]');
dt.year;        // => 5779
dt.month;       // => 6
dt.monthCode;   // => 'M05L'
dt.day;         // => 18
dt.hour;        // => 3
dt.minute;      // => 24
dt.second;      // => 30
dt.millisecond; // => 0
dt.microsecond; // => 3
dt.nanosecond;  // => 500

Trying the same in Deno ignores calendar:

dt = Temporal.ZonedDateTime.from('2019-02-23T03:24:30.000003500[Europe/Rome][u-ca=hebrew]');
dt.year;        // => 2019
dt.month;       // => 2
…

I tried different methods of setting calendar for a ZonedDateTime, like Temporal.Now.zonedDateTime("persian") and obj.withCalendar("persian") with different calendars (Persian, Chinese, Hebrew, Islamic) and all give the same result, which is using ISO 8601 instead of the specified calendar.

petamoriken commented 5 months ago

This is probably a V8 issue. The Temporal specification has been confirmed, but is in the process of being implemented by each JavaScript engine. Therefore, the--unstable-temporal flag is required to enable it.

fyi: test262 conformance as of October 2023 https://ptomato.name/talks/tc39-2023-11/#3