Temporal: ZonedDateTime with out-of-range date should be rejected
Categories
(Core :: JavaScript: Standard Library, defect, P3)
Tracking
()
People
(Reporter: tjc, Unassigned)
References
(Blocks 1 open bug)
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:141.0) Gecko/20100101 Firefox/141.0
Steps to reproduce:
js> Temporal.ZonedDateTime.from('-271821-04-19T11:26:00-12:34[-12:34]').toString()
Actual results:
"-271821-04-19T11:26:00-12:34[-12:34]"
Expected results:
A RangeError should be thrown, according to the spec, which uses CheckISODaysRange: https://tc39.es/proposal-temporal/#sec-temporal-interpretisodatetimeoffset (step 7)
SpiderMonkey's implementation of InterpretISODateTimeOffset calls ISODateTimeWithinLimits instead:
https://searchfox.org/firefox-main/source/js/src/builtin/temporal/ZonedDateTime.cpp#97
but this allows for a date string of -271821-04-19, which is inconsistent with the behavior of CheckISODaysRange.
Comment 1•7 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::JavaScript: Standard Library' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•7 months ago
|
||
I consider this a spec bug -> https://github.com/tc39/proposal-temporal/pull/3014.
For example this works in SpiderMonkey:
js> Temporal.ZonedDateTime.from('-271821-04-19T23:00[Etc/GMT+5]').toString()
"-271821-04-19T23:00:00-05:00[Etc/GMT+5]"
js> Temporal.ZonedDateTime.from('-271821-04-19T23:00[Etc/GMT+5]').offset
"-05:00"
js> Temporal.ZonedDateTime.from('-271821-04-19T23:00-05[-05]').toString()
"-271821-04-19T23:00:00-05:00[-05:00]"
js> Temporal.ZonedDateTime.from('-271821-04-19T23:00-05[-05]').offset
"-05:00"
But when using the spec polyfill:
>> Temporal.ZonedDateTime.from('-271821-04-19T23:00[Etc/GMT+5]').toString()
"-271821-04-19T23:00:00-05:00[Etc/GMT+5]"
>> Temporal.ZonedDateTime.from('-271821-04-19T23:00[Etc/GMT+5]').offset
"-05:00"
>> Temporal.ZonedDateTime.from('-271821-04-19T23:00-05[-05]').toString()
Uncaught RangeError: date/time value is outside the supported range
It doesn't make much sense to me that a time zone offset of -05 is supported when using named time zone, but not when using time zone offset strings.
And it even more confusingly, the spec doesn't apply the same restrictions for the maximum allowed date-time value. This works in both SpiderMonkey and the spec polyfill:
js> Temporal.ZonedDateTime.from('+275760-09-13T01:00[Etc/GMT-9]').toString()
"+275760-09-13T01:00:00+09:00[Etc/GMT-9]"
js> Temporal.ZonedDateTime.from('+275760-09-13T01:00[Etc/GMT-9]').offset
"+09:00"
js> Temporal.ZonedDateTime.from('+275760-09-13T01:00+09[+09]').toString()
"+275760-09-13T01:00:00+09:00[+09:00]"
js> Temporal.ZonedDateTime.from('+275760-09-13T01:00+09[+09]').offset
"+09:00"
Updated•7 months ago
|
Comment 3•3 months ago
|
||
My conclusion is that this is not a spec bug — see discussion starting at https://github.com/tc39/proposal-temporal/pull/3014#issuecomment-3784381106 and particularly https://github.com/tc39/proposal-temporal/pull/3014#issuecomment-3856086253
Description
•