Replace "de"=>"de-AT" and "en"=>"en-US"

Make locales consistent throughout these tests, and splitting into a
separate commit to make it easier to review substantial changes later.
This commit is contained in:
Justin Grant 2022-12-16 12:41:58 -08:00 committed by Richard Gibson
parent f999dea7c0
commit 12ff866707
7 changed files with 47 additions and 47 deletions

View File

@ -21,16 +21,16 @@ function maybeGetWeekdayOnlyFormat() {
}
var date = Temporal.PlainDate.from("1976-11-18T15:23:30");
assert.sameValue(`${ date.toLocaleString("en", { timeZone: "America/New_York" }) }`, "11/18/1976")
assert.sameValue(`${ date.toLocaleString("de", { timeZone: "Europe/Vienna" }) }`, "18.11.1976")
assert.sameValue(`${ date.toLocaleString("en-US", { timeZone: "America/New_York" }) }`, "11/18/1976");
assert.sameValue(`${ date.toLocaleString("de-AT", { timeZone: "Europe/Vienna" }) }`, "18.11.1976");
var fmt = maybeGetWeekdayOnlyFormat();
if (fmt) assert.sameValue(fmt.format(date), "Thursday");
// should ignore units not in the data type
assert.sameValue(date.toLocaleString("en", { timeZoneName: "long" }), "11/18/1976");
assert.sameValue(date.toLocaleString("en", { hour: "numeric" }), "11/18/1976");
assert.sameValue(date.toLocaleString("en", { minute: "numeric" }), "11/18/1976");
assert.sameValue(date.toLocaleString("en", { second: "numeric" }), "11/18/1976");
assert.sameValue(date.toLocaleString("en-US", { timeZoneName: "long" }), "11/18/1976");
assert.sameValue(date.toLocaleString("en-US", { hour: "numeric" }), "11/18/1976");
assert.sameValue(date.toLocaleString("en-US", { minute: "numeric" }), "11/18/1976");
assert.sameValue(date.toLocaleString("en-US", { second: "numeric" }), "11/18/1976");
// works when the object's calendar is the same as the locale's calendar
var d = Temporal.PlainDate.from({

View File

@ -8,7 +8,7 @@ features: [Temporal]
---*/
function maybeGetWeekdayOnlyFormat() {
const fmt = new Intl.DateTimeFormat("en", { weekday: "long", timeZone: "Europe/Vienna" });
const fmt = new Intl.DateTimeFormat("en-US", { weekday: "long", timeZone: "Europe/Vienna" });
if (
["era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"].some(
(prop) => prop in fmt.resolvedOptions()
@ -21,17 +21,17 @@ function maybeGetWeekdayOnlyFormat() {
}
var datetime = Temporal.PlainDateTime.from("1976-11-18T15:23:30");
assert.sameValue(`${datetime.toLocaleString("en", { timeZone: "America/New_York" })}`, "11/18/1976, 3:23:30 PM");
assert.sameValue(`${datetime.toLocaleString("de", { timeZone: "Europe/Vienna" })}`, "18.11.1976, 15:23:30");
assert.sameValue(`${datetime.toLocaleString("en-US", { timeZone: "America/New_York" })}`, "11/18/1976, 3:23:30 PM");
assert.sameValue(`${datetime.toLocaleString("de-AT", { timeZone: "Europe/Vienna" })}`, "18.11.1976, 15:23:30");
var fmt = maybeGetWeekdayOnlyFormat();
if (fmt) assert.sameValue(fmt.format(datetime), "Thursday");
// should ignore units not in the data type
assert.sameValue(datetime.toLocaleString("en", { timeZoneName: "long" }), "11/18/1976, 3:23:30 PM");
assert.sameValue(datetime.toLocaleString("en-US", { timeZoneName: "long" }), "11/18/1976, 3:23:30 PM");
// should use compatible disambiguation option
var dstStart = new Temporal.PlainDateTime(2020, 3, 8, 2, 30);
assert.sameValue(`${dstStart.toLocaleString("en", { timeZone: "America/Los_Angeles" })}`, "3/8/2020, 3:30:00 AM");
assert.sameValue(`${dstStart.toLocaleString("en-US", { timeZone: "America/Los_Angeles" })}`, "3/8/2020, 3:30:00 AM");
// works when the object's calendar is the same as the locale's calendar
var dt = Temporal.PlainDateTime.from({

View File

@ -8,7 +8,7 @@ features: [Temporal]
---*/
function maybeGetWeekdayOnlyFormat() {
const fmt = new Intl.DateTimeFormat("en", { weekday: "long", timeZone: "Europe/Vienna" });
const fmt = new Intl.DateTimeFormat("en-US", { weekday: "long", timeZone: "Europe/Vienna" });
if (
["era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"].some(
(prop) => prop in fmt.resolvedOptions()
@ -21,13 +21,13 @@ function maybeGetWeekdayOnlyFormat() {
}
var instant = Temporal.Instant.from("1976-11-18T14:23:30Z");
assert.sameValue(`${instant.toLocaleString("en", { timeZone: "America/New_York" })}`, "11/18/1976, 9:23:30 AM");
assert.sameValue(`${instant.toLocaleString("de", { timeZone: "Europe/Vienna" })}`, "18.11.1976, 15:23:30");
assert.sameValue(`${instant.toLocaleString("en-US", { timeZone: "America/New_York" })}`, "11/18/1976, 9:23:30 AM");
assert.sameValue(`${instant.toLocaleString("de-AT", { timeZone: "Europe/Vienna" })}`, "18.11.1976, 15:23:30");
var fmt = maybeGetWeekdayOnlyFormat();
if (fmt) assert.sameValue(fmt.format(instant), "Thursday");
// outputs timeZoneName if requested
var str = instant.toLocaleString("en", {
var str = instant.toLocaleString("en-US", {
timeZone: "America/New_York",
timeZoneName: "short"
});

View File

@ -7,25 +7,25 @@ description: monthday.toLocaleString()
features: [Temporal]
---*/
var calendar = new Intl.DateTimeFormat("en").resolvedOptions().calendar;
var calendar = new Intl.DateTimeFormat("en-US").resolvedOptions().calendar;
var monthday = Temporal.PlainMonthDay.from({
monthCode: "M11",
day: 18,
calendar
});
assert.sameValue(`${ monthday.toLocaleString("en", { timeZone: "America/New_York" }) }`, "11/18")
assert.sameValue(`${ monthday.toLocaleString("de", {
assert.sameValue(`${ monthday.toLocaleString("en-US", { timeZone: "America/New_York" }) }`, "11/18");
assert.sameValue(`${ monthday.toLocaleString("de-AT", {
timeZone: "Europe/Vienna",
calendar
}) }`, "18.11.")
}) }`, "18.11.");
// should ignore units not in the data type
assert.sameValue(monthday.toLocaleString("en", { timeZoneName: "long" }), "11/18");
assert.sameValue(monthday.toLocaleString("en", { year: "numeric" }), "11/18");
assert.sameValue(monthday.toLocaleString("en", { hour: "numeric" }), "11/18");
assert.sameValue(monthday.toLocaleString("en", { minute: "numeric" }), "11/18");
assert.sameValue(monthday.toLocaleString("en", { second: "numeric" }), "11/18");
assert.sameValue(monthday.toLocaleString("en", { weekday: "long" }), "11/18");
assert.sameValue(monthday.toLocaleString("en-US", { timeZoneName: "long" }), "11/18");
assert.sameValue(monthday.toLocaleString("en-US", { year: "numeric" }), "11/18");
assert.sameValue(monthday.toLocaleString("en-US", { hour: "numeric" }), "11/18");
assert.sameValue(monthday.toLocaleString("en-US", { minute: "numeric" }), "11/18");
assert.sameValue(monthday.toLocaleString("en-US", { second: "numeric" }), "11/18");
assert.sameValue(monthday.toLocaleString("en-US", { weekday: "long" }), "11/18");
// works when the object's calendar is the same as the locale's calendar
var md = Temporal.PlainMonthDay.from({

View File

@ -8,12 +8,12 @@ features: [Temporal]
---*/
var time = Temporal.PlainTime.from("1976-11-18T15:23:30");
assert.sameValue(`${time.toLocaleString("en", { timeZone: "America/New_York" })}`, "3:23:30 PM");
assert.sameValue(`${time.toLocaleString("de", { timeZone: "Europe/Vienna" })}`, "15:23:30");
assert.sameValue(`${time.toLocaleString("en-US", { timeZone: "America/New_York" })}`, "3:23:30 PM");
assert.sameValue(`${time.toLocaleString("de-AT", { timeZone: "Europe/Vienna" })}`, "15:23:30");
// should ignore units not in the data type
assert.sameValue(time.toLocaleString("en", { timeZoneName: "long" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en", { year: "numeric" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en", { month: "numeric" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en", { day: "numeric" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en", { weekday: "long" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en-US", { timeZoneName: "long" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en-US", { year: "numeric" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en-US", { month: "numeric" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en-US", { day: "numeric" }), "3:23:30 PM");
assert.sameValue(time.toLocaleString("en-US", { weekday: "long" }), "3:23:30 PM");

View File

@ -7,15 +7,15 @@ description: yearmonth.toLocaleString()
features: [Temporal]
---*/
var calendar = new Intl.DateTimeFormat("en").resolvedOptions().calendar;
var calendar = new Intl.DateTimeFormat("en-US").resolvedOptions().calendar;
var yearmonth = Temporal.PlainYearMonth.from({
year: 1976,
month: 11,
calendar
});
assert.sameValue(`${yearmonth.toLocaleString("en", { timeZone: "America/New_York" })}`, "11/1976");
assert.sameValue(`${yearmonth.toLocaleString("en-US", { timeZone: "America/New_York" })}`, "11/1976");
assert.sameValue(
`${yearmonth.toLocaleString("de", {
`${yearmonth.toLocaleString("de-AT", {
timeZone: "Europe/Vienna",
calendar
})}`,
@ -23,12 +23,12 @@ assert.sameValue(
);
// should ignore units not in the data type
assert.sameValue(yearmonth.toLocaleString("en", { timeZoneName: "long" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en", { day: "numeric" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en", { hour: "numeric" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en", { minute: "numeric" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en", { second: "numeric" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en", { weekday: "long" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en-US", { timeZoneName: "long" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en-US", { day: "numeric" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en-US", { hour: "numeric" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en-US", { minute: "numeric" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en-US", { second: "numeric" }), "11/1976");
assert.sameValue(yearmonth.toLocaleString("en-US", { weekday: "long" }), "11/1976");
// works when the object's calendar is the same as the locale's calendar
var ym = Temporal.PlainYearMonth.from({

View File

@ -8,7 +8,7 @@ features: [Temporal]
---*/
function maybeGetWeekdayOnlyFormat() {
const fmt = new Intl.DateTimeFormat("en", { weekday: "long", timeZone: "Europe/Vienna" });
const fmt = new Intl.DateTimeFormat("en-US", { weekday: "long", timeZone: "Europe/Vienna" });
if (
["era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"].some(
(prop) => prop in fmt.resolvedOptions()
@ -21,23 +21,23 @@ function maybeGetWeekdayOnlyFormat() {
}
var zdt = Temporal.ZonedDateTime.from("1976-11-18T15:23:30+01:00[Europe/Vienna]");
assert.sameValue(zdt.toLocaleString("en"), "11/18/1976, 3:23:30 PM GMT+1");
assert.sameValue(zdt.toLocaleString("de"), "18.11.1976, 15:23:30 MEZ");
assert.sameValue(zdt.toLocaleString("en-US"), "11/18/1976, 3:23:30 PM GMT+1");
assert.sameValue(zdt.toLocaleString("de-AT"), "18.11.1976, 15:23:30 MEZ");
const fmt = maybeGetWeekdayOnlyFormat();
// uses only the options in resolvedOptions
if (fmt) assert.sameValue(fmt.format(zdt), "Thursday");
// can override the style of the time zone name
assert.sameValue(
zdt.toLocaleString("en", { timeZoneName: "long" }),
zdt.toLocaleString("en-US", { timeZoneName: "long" }),
"11/18/1976, 3:23:30 PM Central European Standard Time"
);
// works if the time zone given in options agrees with the object's time zone
assert.sameValue(zdt.toLocaleString("en", { timeZone: "Europe/Vienna" }), "11/18/1976, 3:23:30 PM GMT+1");
assert.sameValue(zdt.toLocaleString("en-US", { timeZone: "Europe/Vienna" }), "11/18/1976, 3:23:30 PM GMT+1");
// throws if the time zone given in options disagrees with the object's time zone
assert.throws(RangeError, () => zdt.toLocaleString("en", { timeZone: "America/New_York" }));
assert.throws(RangeError, () => zdt.toLocaleString("en-US", { timeZone: "America/New_York" }));
// works when the object's calendar is the same as the locale's calendar
var zdt = new Temporal.ZonedDateTime(0n, "UTC", "japanese");