From 9a22bba7f15819fbd223a99d822d79cced2e4ad7 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Wed, 9 Feb 2022 15:59:37 +0100 Subject: [PATCH 1/5] Check a variety of offset Etc/GMT timezones --- .../intl402/Temporal/TimeZone/etc-timezone.js | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 test/intl402/Temporal/TimeZone/etc-timezone.js diff --git a/test/intl402/Temporal/TimeZone/etc-timezone.js b/test/intl402/Temporal/TimeZone/etc-timezone.js new file mode 100644 index 00000000000..07e533a601d --- /dev/null +++ b/test/intl402/Temporal/TimeZone/etc-timezone.js @@ -0,0 +1,65 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone +description: Some Etc/GMT{+/-}{0}N timezones are valid, but not all +features: [Temporal] +---*/ + +// "Etc/GMT-0" through "Etc/GMT-14" are OK + +assert.sameValue( + Temporal.TimeZone.from("Etc/GMT-0").toString(), + "UTC", // if the offset is -0, we say "UTC" rather than "GMT" + "Etc/GMT-0 is a valid timezone" +); + +[1,2,3,4,5,6,7,8,9,10,11,12,13,14].forEach((n) => { + let tz = "Etc/GMT-" + n; + let instance = Temporal.TimeZone.from(tz); + assert.sameValue( + instance.toString(), + tz, + tz + " is a valid timezone" + ); +}); + +// "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9) +[1,2,3,4,5,6,7,8,9].forEach((n) => { + let tz = "Etc/GMT-0" + n; + assert.throws( + RangeError, + () => { Temporal.TimeZone.from(tz); }, + tz + " is an invalid timezone" + ); +}); + +// "Etc/GMT+0N" is not OK (0 ≤ N ≤ 9) +[0,1,2,3,4,5,6,7,8,9].forEach((n) => { + let tz = "Etc/GMT+0" + n; + assert.throws( + RangeError, + () => { Temporal.TimeZone.from(tz); }, + tz + " is an invalid timezone" + ); +}); + +// Etc/GMT+0" through "Etc/GMT+9" are OK + +// zero is handled in its own way: +assert.sameValue( + Temporal.TimeZone.from("Etc/GMT+0").toString(), + "UTC", // if the offset is +0, we say "UTC" rather than "GMT" + "Etc/GMT+0 is a valid timezone" +); + +[1,2,3,4,5,6,7,8,9, 10, 11, 12].forEach((n) => { + let tz = "Etc/GMT+" + n; + let instance = Temporal.TimeZone.from(tz); + assert.sameValue( + instance.toString(), + tz, + tz + " is a valid timezone" + ); +}); From 421816716f962db401a9514e7ea190505ea73b58 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Tue, 15 Feb 2022 11:08:29 +0100 Subject: [PATCH 2/5] Use constructor rather than static `from` method --- .../intl402/Temporal/TimeZone/etc-timezone.js | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/test/intl402/Temporal/TimeZone/etc-timezone.js b/test/intl402/Temporal/TimeZone/etc-timezone.js index 07e533a601d..fd76d380483 100644 --- a/test/intl402/Temporal/TimeZone/etc-timezone.js +++ b/test/intl402/Temporal/TimeZone/etc-timezone.js @@ -10,14 +10,14 @@ features: [Temporal] // "Etc/GMT-0" through "Etc/GMT-14" are OK assert.sameValue( - Temporal.TimeZone.from("Etc/GMT-0").toString(), + (new Temporal.TimeZone("Etc/GMT-0")).toString(), "UTC", // if the offset is -0, we say "UTC" rather than "GMT" "Etc/GMT-0 is a valid timezone" ); [1,2,3,4,5,6,7,8,9,10,11,12,13,14].forEach((n) => { let tz = "Etc/GMT-" + n; - let instance = Temporal.TimeZone.from(tz); + let instance = new Temporal.TimeZone(tz); assert.sameValue( instance.toString(), tz, @@ -25,12 +25,19 @@ assert.sameValue( ); }); +let gmtMinus15TZ = "Etc/GMT-15"; +assert.throws( + RangeError, + () => { new Temporal.TimeZone(gmtMinus15TZ); }, + gmtMinus15TZ + " is an invalid timezone" +); + // "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9) [1,2,3,4,5,6,7,8,9].forEach((n) => { let tz = "Etc/GMT-0" + n; assert.throws( RangeError, - () => { Temporal.TimeZone.from(tz); }, + () => { new Temporal.TimeZone(tz); }, tz + " is an invalid timezone" ); }); @@ -40,26 +47,35 @@ assert.sameValue( let tz = "Etc/GMT+0" + n; assert.throws( RangeError, - () => { Temporal.TimeZone.from(tz); }, + () => { new Temporal.TimeZone(tz); }, tz + " is an invalid timezone" ); }); -// Etc/GMT+0" through "Etc/GMT+9" are OK +// Etc/GMT+0" through "Etc/GMT+12" are OK -// zero is handled in its own way: +// zero is handled in its own way (say "UTC" rather than "GMT"): assert.sameValue( - Temporal.TimeZone.from("Etc/GMT+0").toString(), + (new Temporal.TimeZone("Etc/GMT+0")).toString(), "UTC", // if the offset is +0, we say "UTC" rather than "GMT" "Etc/GMT+0 is a valid timezone" ); [1,2,3,4,5,6,7,8,9, 10, 11, 12].forEach((n) => { let tz = "Etc/GMT+" + n; - let instance = Temporal.TimeZone.from(tz); + let instance = new Temporal.TimeZone(tz); assert.sameValue( instance.toString(), tz, tz + " is a valid timezone" ); }); + +// "Etc/GMT+13" is not OK + +let gmtPlus13TZ = "Etc/GMT+13"; +assert.throws( + RangeError, + () => { new Temporal.TimeZone(gmtPlus13TZ); }, + gmtPlus13TZ + " is an invalid timezone" +); From 472916d31617f4e8d167899776eda53a526d2e86 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Mon, 21 Feb 2022 14:24:52 +0100 Subject: [PATCH 3/5] Update test/intl402/Temporal/TimeZone/etc-timezone.js Co-authored-by: Richard Gibson --- test/intl402/Temporal/TimeZone/etc-timezone.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/intl402/Temporal/TimeZone/etc-timezone.js b/test/intl402/Temporal/TimeZone/etc-timezone.js index fd76d380483..42853751687 100644 --- a/test/intl402/Temporal/TimeZone/etc-timezone.js +++ b/test/intl402/Temporal/TimeZone/etc-timezone.js @@ -25,11 +25,11 @@ assert.sameValue( ); }); -let gmtMinus15TZ = "Etc/GMT-15"; +let gmtMinus24TZ = "Etc/GMT-24"; assert.throws( RangeError, - () => { new Temporal.TimeZone(gmtMinus15TZ); }, - gmtMinus15TZ + " is an invalid timezone" + () => { new Temporal.TimeZone(gmtMinus24TZ); }, + gmtMinus24TZ + " is an invalid timezone" ); // "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9) From 54f7e8fafcfbfd09627d556ec5d4056a7745a1ce Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Mon, 21 Feb 2022 14:25:23 +0100 Subject: [PATCH 4/5] Fix spacing --- test/intl402/Temporal/TimeZone/etc-timezone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/intl402/Temporal/TimeZone/etc-timezone.js b/test/intl402/Temporal/TimeZone/etc-timezone.js index 42853751687..b95ff33fbe6 100644 --- a/test/intl402/Temporal/TimeZone/etc-timezone.js +++ b/test/intl402/Temporal/TimeZone/etc-timezone.js @@ -61,7 +61,7 @@ assert.sameValue( "Etc/GMT+0 is a valid timezone" ); -[1,2,3,4,5,6,7,8,9, 10, 11, 12].forEach((n) => { +[1,2,3,4,5,6,7,8,9,10,11,12].forEach((n) => { let tz = "Etc/GMT+" + n; let instance = new Temporal.TimeZone(tz); assert.sameValue( From 11228b68e1017f8399dc2243d677bd7fd82ee566 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Mon, 21 Feb 2022 14:26:08 +0100 Subject: [PATCH 5/5] Update test/intl402/Temporal/TimeZone/etc-timezone.js Co-authored-by: Richard Gibson --- test/intl402/Temporal/TimeZone/etc-timezone.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/intl402/Temporal/TimeZone/etc-timezone.js b/test/intl402/Temporal/TimeZone/etc-timezone.js index b95ff33fbe6..b3995e5f4ca 100644 --- a/test/intl402/Temporal/TimeZone/etc-timezone.js +++ b/test/intl402/Temporal/TimeZone/etc-timezone.js @@ -71,11 +71,9 @@ assert.sameValue( ); }); -// "Etc/GMT+13" is not OK - -let gmtPlus13TZ = "Etc/GMT+13"; +let gmtPlus24TZ = "Etc/GMT+24"; assert.throws( RangeError, - () => { new Temporal.TimeZone(gmtPlus13TZ); }, - gmtPlus13TZ + " is an invalid timezone" + () => { new Temporal.TimeZone(gmtPlus24TZ); }, + gmtPlus24TZ + " is an invalid timezone" );