mirror of https://github.com/tc39/test262.git
Some progress on not using time zone names that require Intl
In order to test this functionality on hosts that don't have Intl, we have to use "UTC" and offset-only time zones here, as the full set of IANA time zone names are not required to be supported across all hosts. This makes some progress on https://github.com/tc39/test262/issues/3253
This commit is contained in:
parent
e3395bb1e4
commit
af00d69c39
|
@ -7,11 +7,11 @@ description: Conversion of ISO date-time strings to Temporal.Instant instances
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.TimeZone("America/Vancouver");
|
||||
const instance = new Temporal.TimeZone("UTC");
|
||||
|
||||
let str = "1970-01-01T00:00";
|
||||
assert.throws(RangeError, () => instance.getNextTransition(str), "bare date-time string is not an instant");
|
||||
str = "1970-01-01T00:00[America/Vancouver]";
|
||||
str = "1970-01-01T00:00[UTC]";
|
||||
assert.throws(RangeError, () => instance.getNextTransition(str), "date-time + IANA annotation is not an instant");
|
||||
|
||||
// The following are all valid strings so should not throw:
|
||||
|
@ -19,8 +19,8 @@ assert.throws(RangeError, () => instance.getNextTransition(str), "date-time + IA
|
|||
const valids = [
|
||||
"1970-01-01T00:00Z",
|
||||
"1970-01-01T00:00+01:00",
|
||||
"1970-01-01T00:00Z[America/Vancouver]",
|
||||
"1970-01-01T00:00+01:00[America/Vancouver]",
|
||||
"1970-01-01T00:00Z[UTC]",
|
||||
"1970-01-01T00:00+01:00[UTC]",
|
||||
];
|
||||
for (const str of valids) {
|
||||
const result = instance.getNextTransition(str);
|
||||
|
|
|
@ -11,7 +11,7 @@ const instance = new Temporal.TimeZone("UTC");
|
|||
|
||||
let str = "1970-01-01T00:00";
|
||||
assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "bare date-time string is not an instant");
|
||||
str = "1970-01-01T00:00[America/Vancouver]";
|
||||
str = "1970-01-01T00:00[UTC]";
|
||||
assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "date-time + IANA annotation is not an instant");
|
||||
|
||||
// The following are all valid strings so should not throw:
|
||||
|
@ -19,8 +19,8 @@ assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "date-tim
|
|||
const valids = [
|
||||
"1970-01-01T00:00Z",
|
||||
"1970-01-01T00:00+01:00",
|
||||
"1970-01-01T00:00Z[America/Vancouver]",
|
||||
"1970-01-01T00:00+01:00[America/Vancouver]",
|
||||
"1970-01-01T00:00Z[UTC]",
|
||||
"1970-01-01T00:00+01:00[UTC]",
|
||||
];
|
||||
for (const str of valids) {
|
||||
const result = instance.getOffsetNanosecondsFor(str);
|
||||
|
|
|
@ -11,7 +11,7 @@ const instance = new Temporal.TimeZone("UTC");
|
|||
|
||||
let str = "1970-01-01T00:00";
|
||||
assert.throws(RangeError, () => instance.getOffsetStringFor(str), "bare date-time string is not an instant");
|
||||
str = "1970-01-01T00:00[America/Vancouver]";
|
||||
str = "1970-01-01T00:00[UTC]";
|
||||
assert.throws(RangeError, () => instance.getOffsetStringFor(str), "date-time + IANA annotation is not an instant");
|
||||
|
||||
// The following are all valid strings so should not throw:
|
||||
|
@ -19,8 +19,8 @@ assert.throws(RangeError, () => instance.getOffsetStringFor(str), "date-time + I
|
|||
const valids = [
|
||||
"1970-01-01T00:00Z",
|
||||
"1970-01-01T00:00+01:00",
|
||||
"1970-01-01T00:00Z[America/Vancouver]",
|
||||
"1970-01-01T00:00+01:00[America/Vancouver]",
|
||||
"1970-01-01T00:00Z[UTC]",
|
||||
"1970-01-01T00:00+01:00[UTC]",
|
||||
];
|
||||
for (const str of valids) {
|
||||
const result = instance.getOffsetStringFor(str);
|
||||
|
|
|
@ -7,11 +7,11 @@ description: Conversion of ISO date-time strings to Temporal.Instant instances
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.TimeZone("America/Vancouver");
|
||||
const instance = new Temporal.TimeZone("UTC");
|
||||
|
||||
let str = "1970-01-01T00:00";
|
||||
assert.throws(RangeError, () => instance.getPreviousTransition(str), "bare date-time string is not an instant");
|
||||
str = "1970-01-01T00:00[America/Vancouver]";
|
||||
str = "1970-01-01T00:00[UTC]";
|
||||
assert.throws(RangeError, () => instance.getPreviousTransition(str), "date-time + IANA annotation is not an instant");
|
||||
|
||||
// The following are all valid strings so should not throw:
|
||||
|
@ -19,8 +19,8 @@ assert.throws(RangeError, () => instance.getPreviousTransition(str), "date-time
|
|||
const valids = [
|
||||
"1970-01-01T00:00Z",
|
||||
"1970-01-01T00:00+01:00",
|
||||
"1970-01-01T00:00Z[America/Vancouver]",
|
||||
"1970-01-01T00:00+01:00[America/Vancouver]",
|
||||
"1970-01-01T00:00Z[UTC]",
|
||||
"1970-01-01T00:00+01:00[UTC]",
|
||||
];
|
||||
for (const str of valids) {
|
||||
const result = instance.getPreviousTransition(str);
|
||||
|
|
|
@ -7,7 +7,8 @@ description: Conversion of ISO date-time strings to Temporal.ZonedDateTime insta
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "Europe/Berlin");
|
||||
const timeZone = new Temporal.TimeZone("+01:00");
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone);
|
||||
|
||||
let str = "1970-01-01T00:00";
|
||||
assert.throws(RangeError, () => instance.equals(str), "bare date-time string is not a ZonedDateTime");
|
||||
|
@ -16,17 +17,17 @@ assert.throws(RangeError, () => instance.equals(str), "date-time + Z is not a Zo
|
|||
str = "1970-01-01T00:00+01:00";
|
||||
assert.throws(RangeError, () => instance.equals(str), "date-time + offset is not a ZonedDateTime");
|
||||
|
||||
str = "1970-01-01T00:00[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00[+01:00]";
|
||||
const result1 = instance.equals(str);
|
||||
assert.sameValue(result1, false, "date-time + IANA annotation preserves wall time in the time zone");
|
||||
|
||||
str = "1970-01-01T00:00Z[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00Z[+01:00]";
|
||||
const result2 = instance.equals(str);
|
||||
assert.sameValue(result2, true, "date-time + Z + IANA annotation preserves exact time in the time zone");
|
||||
|
||||
str = "1970-01-01T00:00+01:00[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00+01:00[+01:00]";
|
||||
const result3 = instance.equals(str);
|
||||
assert.sameValue(result3, false, "date-time + offset + IANA annotation ensures both exact and wall time match");
|
||||
|
||||
str = "1970-01-01T00:00-04:15[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00-04:15[+01:00]";
|
||||
assert.throws(RangeError, () => instance.equals(str), "date-time + offset + IANA annotation throws if wall time and exact time mismatch");
|
||||
|
|
|
@ -8,7 +8,8 @@ includes: [temporalHelpers.js]
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone);
|
||||
|
||||
let str = "1970-01-01T00:00";
|
||||
assert.throws(RangeError, () => instance.since(str), "bare date-time string is not a ZonedDateTime");
|
||||
|
@ -17,17 +18,17 @@ assert.throws(RangeError, () => instance.since(str), "date-time + Z is not a Zon
|
|||
str = "1970-01-01T00:00+01:00";
|
||||
assert.throws(RangeError, () => instance.since(str), "date-time + offset is not a ZonedDateTime");
|
||||
|
||||
str = "1970-01-01T00:00[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00[+01:00]";
|
||||
const result1 = instance.since(str);
|
||||
TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "date-time + IANA annotation preserves wall time in the time zone");
|
||||
|
||||
str = "1970-01-01T00:00Z[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00Z[+01:00]";
|
||||
const result2 = instance.since(str);
|
||||
TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation preserves exact time in the time zone");
|
||||
|
||||
str = "1970-01-01T00:00+01:00[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00+01:00[+01:00]";
|
||||
const result3 = instance.since(str);
|
||||
TemporalHelpers.assertDuration(result3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation ensures both exact and wall time match");
|
||||
|
||||
str = "1970-01-01T00:00-04:15[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00-04:15[+01:00]";
|
||||
assert.throws(RangeError, () => instance.since(str), "date-time + offset + IANA annotation throws if wall time and exact time mismatch");
|
||||
|
|
|
@ -8,7 +8,8 @@ includes: [temporalHelpers.js]
|
|||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone);
|
||||
|
||||
let str = "1970-01-01T00:00";
|
||||
assert.throws(RangeError, () => instance.until(str), "bare date-time string is not a ZonedDateTime");
|
||||
|
@ -17,17 +18,17 @@ assert.throws(RangeError, () => instance.until(str), "date-time + Z is not a Zon
|
|||
str = "1970-01-01T00:00+01:00";
|
||||
assert.throws(RangeError, () => instance.until(str), "date-time + offset is not a ZonedDateTime");
|
||||
|
||||
str = "1970-01-01T00:00[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00[+01:00]";
|
||||
const result1 = instance.until(str);
|
||||
TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, "date-time + IANA annotation preserves wall time in the time zone");
|
||||
|
||||
str = "1970-01-01T00:00Z[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00Z[+01:00]";
|
||||
const result2 = instance.until(str);
|
||||
TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation preserves exact time in the time zone");
|
||||
|
||||
str = "1970-01-01T00:00+01:00[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00+01:00[+01:00]";
|
||||
const result3 = instance.until(str);
|
||||
TemporalHelpers.assertDuration(result3, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation ensures both exact and wall time match");
|
||||
|
||||
str = "1970-01-01T00:00-04:15[Europe/Berlin]";
|
||||
str = "1970-01-01T00:00-04:15[+01:00]";
|
||||
assert.throws(RangeError, () => instance.until(str), "date-time + offset + IANA annotation throws if wall time and exact time mismatch");
|
||||
|
|
Loading…
Reference in New Issue