Skip to content
Permalink
Browse files
[Temporal] Years 0-999 should be canonically represented with 4 digit…
…s, not 6

https://bugs.webkit.org/show_bug.cgi?id=240294

Reviewed by Yusuke Suzuki.

This patch implements the spec change of tc39/proposal-temporal#2082:
The range for 4-digit years in ISO8601 date strings should be 0-9999, not 1000-9999.

* test262/expectations.yaml:
Mark four test cases as passing.

* runtime/TemporalInstant.cpp:

Canonical link: https://commits.webkit.org/250456@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294050 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rkirsling committed May 11, 2022
1 parent 38f99b1 commit 10c0921fc36f35af8c39611b1508fba8ad866790
Showing with 24 additions and 8 deletions.
  1. +10 −0 JSTests/ChangeLog
  2. +0 −6 JSTests/test262/expectations.yaml
  3. +12 −0 Source/JavaScriptCore/ChangeLog
  4. +2 −2 Source/JavaScriptCore/runtime/TemporalInstant.cpp
@@ -1,3 +1,13 @@
2022-05-10 Ross Kirsling <ross.kirsling@sony.com>

[Temporal] Years 0-999 should be canonically represented with 4 digits, not 6
https://bugs.webkit.org/show_bug.cgi?id=240294

Reviewed by Yusuke Suzuki.

* test262/expectations.yaml:
Mark four test cases as passing.

2022-05-09 Yusuke Suzuki <ysuzuki@apple.com>

Upstream TypedArray.prototype.fill speedup from bun
@@ -1050,9 +1050,6 @@ test/built-ins/Temporal/Instant/prototype/since/largestunit.js:
test/built-ins/Temporal/Instant/prototype/toJSON/timezone-getoffsetnanosecondsfor-not-callable.js:
default: 'Test262Error: Uncallable undefined getOffsetNanosecondsFor should throw TypeError Expected a TypeError to be thrown but no exception was thrown at all'
strict mode: 'Test262Error: Uncallable undefined getOffsetNanosecondsFor should throw TypeError Expected a TypeError to be thrown but no exception was thrown at all'
test/built-ins/Temporal/Instant/prototype/toJSON/year-format.js:
default: 'Test262Error: year 0 formatted as 4-digit Expected SameValue(«+000000-07-01T21:30:36Z», «0000-07-01T21:30:36Z») to be true'
strict mode: 'Test262Error: year 0 formatted as 4-digit Expected SameValue(«+000000-07-01T21:30:36Z», «0000-07-01T21:30:36Z») to be true'
test/built-ins/Temporal/Instant/prototype/toString/rounding-direction.js:
default: 'Test262Error: Rounding down is towards the Big Bang, not the epoch or 1 BCE (roundingMode trunc) Expected SameValue(«-000099-12-15T12:00:01Z», «-000099-12-15T12:00:00Z») to be true'
strict mode: 'Test262Error: Rounding down is towards the Big Bang, not the epoch or 1 BCE (roundingMode trunc) Expected SameValue(«-000099-12-15T12:00:01Z», «-000099-12-15T12:00:00Z») to be true'
@@ -1068,9 +1065,6 @@ test/built-ins/Temporal/Instant/prototype/toString/timezone-string-leap-second.j
test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js:
default: 'RangeError: argument needs to be UTC offset string, TimeZone identifier, or temporal Instant string'
strict mode: 'RangeError: argument needs to be UTC offset string, TimeZone identifier, or temporal Instant string'
test/built-ins/Temporal/Instant/prototype/toString/year-format.js:
default: 'Test262Error: year 0 formatted as 4-digit Expected SameValue(«+000000-07-01T21:30:36Z», «0000-07-01T21:30:36Z») to be true'
strict mode: 'Test262Error: year 0 formatted as 4-digit Expected SameValue(«+000000-07-01T21:30:36Z», «0000-07-01T21:30:36Z») to be true'
test/built-ins/Temporal/PlainTime/compare/argument-cast.js:
default: 'TypeError: "microsecond" field is missing'
strict mode: 'TypeError: "microsecond" field is missing'
@@ -1,3 +1,15 @@
2022-05-10 Ross Kirsling <ross.kirsling@sony.com>

[Temporal] Years 0-999 should be canonically represented with 4 digits, not 6
https://bugs.webkit.org/show_bug.cgi?id=240294

Reviewed by Yusuke Suzuki.

This patch implements the spec change of https://github.com/tc39/proposal-temporal/issues/2082:
The range for 4-digit years in ISO8601 date strings should be 0-9999, not 1000-9999.

* runtime/TemporalInstant.cpp:

2022-05-09 Yusuke Suzuki <ysuzuki@apple.com>

Upstream TypedArray.prototype.fill speedup from bun
@@ -457,10 +457,10 @@ String TemporalInstant::toString(ISO8601::ExactTime exactTime, JSObject* timeZon
GregorianDateTime gregorianDateTime { static_cast<double>(exactTime.epochMilliseconds()), LocalTimeOffset { } };
StringBuilder builder;

// If the year is outside the bounds of 1000 and 9999 inclusive we want to
// If the year is outside the bounds of 0 and 9999 inclusive we want to
// use the extended year format (PadISOYear).
unsigned yearLength = 4;
if (gregorianDateTime.year() > 9999 || gregorianDateTime.year() < 1000) {
if (gregorianDateTime.year() > 9999 || gregorianDateTime.year() < 0) {
builder.append(gregorianDateTime.year() < 0 ? '-' : '+');
yearLength = 6;
}

0 comments on commit 10c0921

Please sign in to comment.