deno icon indicating copy to clipboard operation
deno copied to clipboard

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

Open mostafah opened this issue 1 year ago • 1 comments

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.

mostafah avatar Jan 27 '24 02:01 mostafah

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

petamoriken avatar Jan 27 '24 09:01 petamoriken