diff --git a/test/intl402/Temporal/Instant/prototype/toLocaleString/default-includes-time-not-time-zone-name.js b/test/intl402/Temporal/Instant/prototype/toLocaleString/default-includes-time-not-time-zone-name.js new file mode 100644 index 0000000000..5b7b78f1dd --- /dev/null +++ b/test/intl402/Temporal/Instant/prototype/toLocaleString/default-includes-time-not-time-zone-name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.tolocalestring +description: Tests what information is present by default +locale: [en] +features: [Temporal] +---*/ + +const instant = new Temporal.Instant(1735213600_321_000_000n); // 2024-12-26T11:46:40.321Z +const result = instant.toLocaleString("en", { timeZone: "UTC" }); + +assert(result.includes("2024"), `Instant formatted with no options ${result} should include year`); +assert(result.includes("12") || result.includes("Dec"), `Instant formatted with no options ${result} should include month`); +assert(result.includes("26"), `Instant formatted with no options ${result} should include day`); +assert(result.includes("11"), `Instant formatted with no options ${result} should include hour`); +assert(result.includes("46"), `Instant formatted with no options ${result} should include minute`); +assert(result.includes("40"), `Instant formatted with no options ${result} should include second`); +assert(!result.includes("321"), `Instant formatted with no options ${result} should not include fractional second digits`); +assert( + !result.includes("UTC") && !result.includes("Coordinated Universal Time"), + `Instant formatted with no options ${result} should not include time zone name` +); diff --git a/test/intl402/Temporal/PlainDate/prototype/toLocaleString/default-does-not-include-time-and-time-zone-name.js b/test/intl402/Temporal/PlainDate/prototype/toLocaleString/default-does-not-include-time-and-time-zone-name.js new file mode 100644 index 0000000000..8fa20057fa --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toLocaleString/default-does-not-include-time-and-time-zone-name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tolocalestring +description: Tests what information is present by default +locale: [en] +features: [Temporal] +---*/ + +const plainDate = new Temporal.PlainDate(2024, 12, 26); +const result = plainDate.toLocaleString("en", { timeZone: "UTC" }); + +assert(result.includes("2024"), `PlainDate formatted with no options ${result} should include year`); +assert(result.includes("12") || result.includes("Dec"), `PlainDate formatted with no options ${result} should include month`); +assert(result.includes("26"), `PlainDate formatted with no options ${result} should include day`); +assert(!result.includes("00"), `PlainDate formatted with no options ${result} should not include hour, minute, second`); +assert( + !result.includes("UTC") && !result.includes("Coordinated Universal Time"), + `PlainDate formatted with no options ${result} should not include time zone name` +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/default-includes-time-not-time-zone-name.js b/test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/default-includes-time-not-time-zone-name.js new file mode 100644 index 0000000000..654fc01727 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/default-includes-time-not-time-zone-name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tolocalestring +description: Tests what information is present by default +locale: [en] +features: [Temporal] +---*/ + +const plainDateTime = new Temporal.PlainDateTime(2024, 12, 26, 11, 46, 40, 321); +const result = plainDateTime.toLocaleString("en", { timeZone: "UTC" }); + +assert(result.includes("2024"), `PlainDateTime formatted with no options ${result} should include year`); +assert(result.includes("12") || result.includes("Dec"), `PlainDateTime formatted with no options ${result} should include month`); +assert(result.includes("26"), `PlainDateTime formatted with no options ${result} should include day`); +assert(result.includes("11"), `PlainDateTime formatted with no options ${result} should include hour`); +assert(result.includes("46"), `PlainDateTime formatted with no options ${result} should include minute`); +assert(result.includes("40"), `PlainDateTime formatted with no options ${result} should include second`); +assert(!result.includes("321"), `PlainDateTime formatted with no options ${result} should not include fractional second digits`); +assert( + !result.includes("UTC") && !result.includes("Coordinated Universal Time"), + `PlainDateTime formatted with no options ${result} should not include time zone name` +); diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/default-does-not-include-year-time-and-time-zone-name.js b/test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/default-does-not-include-year-time-and-time-zone-name.js new file mode 100644 index 0000000000..06ba488394 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/default-does-not-include-year-time-and-time-zone-name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tolocalestring +description: Tests what information is present by default +locale: [en-u-ca-iso8601] +features: [Temporal] +---*/ + +const plainMonthDay = new Temporal.PlainMonthDay(12, 26); +const result = plainMonthDay.toLocaleString("en-u-ca-iso8601", { timeZone: "UTC" }); + +assert(!result.includes("1972"), `PlainMonthDay formatted with no options ${result} should not include reference year`); +assert(result.includes("12") || result.includes("Dec"), `PlainMonthDay formatted with no options ${result} should include month`); +assert(result.includes("26"), `PlainMonthDay formatted with no options ${result} should include day`); +assert(!result.includes("00"), `PlainMonthDay formatted with no options ${result} should not include hour, minute, second`); +assert( + !result.includes("UTC") && !result.includes("Coordinated Universal Time"), + `PlainMonthDay formatted with no options ${result} should not include time zone name` +); diff --git a/test/intl402/Temporal/PlainTime/prototype/toLocaleString/default-does-not-include-date-and-time-zone-name.js b/test/intl402/Temporal/PlainTime/prototype/toLocaleString/default-does-not-include-date-and-time-zone-name.js new file mode 100644 index 0000000000..b9b95bb961 --- /dev/null +++ b/test/intl402/Temporal/PlainTime/prototype/toLocaleString/default-does-not-include-date-and-time-zone-name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.tolocalestring +description: Tests what information is present by default +locale: [en] +features: [Temporal] +---*/ + +const plainTime = new Temporal.PlainTime(11, 46, 40, 321); +const result = plainTime.toLocaleString("en", { timeZone: "UTC" }); + +assert(!result.includes("1970"), `PlainTime formatted with no options ${result} should not include year`); +assert(!result.includes("01") && !result.includes("Jan"), `PlainTime formatted with no options ${result} should not include month or day`); +assert(result.includes("11"), `PlainTime formatted with no options ${result} should include hour`); +assert(result.includes("46"), `PlainTime formatted with no options ${result} should include minute`); +assert(result.includes("40"), `PlainTime formatted with no options ${result} should include second`); +assert(!result.includes("321"), `PlainTime formatted with no options ${result} should not include fractional second digits`); +assert( + !result.includes("UTC") && !result.includes("Coordinated Universal Time"), + `PlainTime formatted with no options ${result} should not include time zone name` +); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/default-does-not-include-day-time-and-time-zone-name.js b/test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/default-does-not-include-day-time-and-time-zone-name.js new file mode 100644 index 0000000000..4401aecbac --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/default-does-not-include-day-time-and-time-zone-name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.tolocalestring +description: Tests what information is present by default +locale: [en-u-ca-iso8601] +features: [Temporal] +---*/ + +const plainYearMonth = new Temporal.PlainYearMonth(2024, 12, "iso8601", 26); // nonstandard reference day +const result = plainYearMonth.toLocaleString("en-u-ca-iso8601", { timeZone: "UTC" }); + +assert(result.includes("2024"), `PlainYearMonth formatted with no options ${result} should include year`); +assert(result.includes("12") || result.includes("Dec"), `PlainYearMonth formatted with no options ${result} should include month`); +assert(!result.includes("26"), `PlainYearMonth formatted with no options ${result} should not include reference day`); +assert(!result.includes("00"), `PlainYearMonth formatted with no options ${result} should not include hour, minute, second`); +assert( + !result.includes("UTC") && !result.includes("Coordinated Universal Time"), + `PlainYearMonth formatted with no options ${result} should not include time zone name` +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/default-includes-time-and-time-zone-name.js b/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/default-includes-time-and-time-zone-name.js new file mode 100644 index 0000000000..b4275f62ee --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/default-includes-time-and-time-zone-name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.tolocalestring +description: Tests what information is present by default +locale: [en] +features: [Temporal] +---*/ + +const zonedDateTime = new Temporal.ZonedDateTime(1735213600_321_000_000n, "UTC"); // 2024-12-26T11:46:40.321Z +const result = zonedDateTime.toLocaleString("en"); + +assert(result.includes("2024"), `ZonedDateTime formatted with no options ${result} should include year`); +assert(result.includes("12") || result.includes("Dec"), `ZonedDateTime formatted with no options ${result} should include month`); +assert(result.includes("26"), `ZonedDateTime formatted with no options ${result} should include day`); +assert(result.includes("11"), `ZonedDateTime formatted with no options ${result} should include hour`); +assert(result.includes("46"), `ZonedDateTime formatted with no options ${result} should include minute`); +assert(result.includes("40"), `ZonedDateTime formatted with no options ${result} should include second`); +assert(!result.includes("321"), `ZonedDateTime formatted with no options ${result} should not include fractional second digits`); +assert( + result.includes("UTC") || result.includes("Coordinated Universal Time"), + `ZonedDateTime formatted with no options ${result} should include time zone name` +);