Select the types of activity you want to include in your feed.
[Temporal] Test use of toLocaleString with hourCycle
Add tests that toLocaleString uses the hourCycle parameter properly when formatting the string. Test PlainDateTime, PlainTime, Instant, and ZonedDateTime.
···11+// Copyright (C) 2025 Igalia, S.L. All rights reserved.
22+// This code is governed by the BSD license found in the LICENSE file.
33+44+/*---
55+esid: sec-temporal.instant.prototype.tolocalestring
66+description: Hour cycle should be correctly set when defaults are used
77+features: [Temporal]
88+---*/
99+1010+const output0 = "00:00:00";
1111+const output11 = "0:00:00";
1212+const output12 = "12:00:00";
1313+const output24 = "24:00:00";
1414+1515+const item = new Temporal.Instant(0n);
1616+var result = item.toLocaleString("en", { hour12: false, timeZone: "UTC" });
1717+assert.sameValue(result.includes(output0), true, `output for hour12: false should include ${output0}`);
1818+1919+result = item.toLocaleString("en", { hour12: true, timeZone: "UTC" });
2020+assert.sameValue(result.includes(output12), true, `output for hour12: true should include ${output12}`);
2121+2222+result = item.toLocaleString("en", { hourCycle: "h23", timeZone: "UTC" });
2323+assert.sameValue(result.includes(output0), true, `output for hourCycle: h23 should include ${output0}`);
2424+2525+result = item.toLocaleString("en", { hourCycle: "h24", timeZone: "UTC" });
2626+assert.sameValue(result.includes(output24), true, `output for hourCycle: h24 should include ${output24}`);
2727+2828+result = item.toLocaleString("en", { hourCycle: "h11", timeZone: "UTC" });
2929+assert.sameValue(result.includes(output11), true, `output for hourCycle: h11 should include ${output11}`);
3030+3131+result = item.toLocaleString("en", { hourCycle: "h12", timeZone: "UTC" });
3232+assert.sameValue(result.includes(output12), true, `output for hourCycle: h12 should include ${output12}`);
···11+// Copyright (C) 2025 Igalia, S.L. All rights reserved.
22+// This code is governed by the BSD license found in the LICENSE file.
33+44+/*---
55+esid: sec-temporal.plaintime.prototype.tolocalestring
66+description: Hour cycle should be correctly set when defaults are used
77+features: [Temporal]
88+---*/
99+1010+const output0 = "00:00:00";
1111+const output11 = "0:00:00";
1212+const output12 = "12:00:00";
1313+const output24 = "24:00:00";
1414+1515+const item = new Temporal.PlainTime(0, 0);
1616+var result = item.toLocaleString("en", { hour12: false, timeZone: "UTC" });
1717+assert.sameValue(result.includes(output0), true, `output for hour12: false should include ${output0}`);
1818+1919+result = item.toLocaleString("en", { hour12: true, timeZone: "UTC" });
2020+assert.sameValue(result.includes(output12), true, `output for hour12: true should include ${output12}`);
2121+2222+result = item.toLocaleString("en", { hourCycle: "h23", timeZone: "UTC" });
2323+assert.sameValue(result.includes(output0), true, `output for hourCycle: h23 should include ${output0}`);
2424+2525+result = item.toLocaleString("en", { hourCycle: "h24", timeZone: "UTC" });
2626+assert.sameValue(result.includes(output24), true, `output for hourCycle: h24 should include ${output24}`);
2727+2828+result = item.toLocaleString("en", { hourCycle: "h11", timeZone: "UTC" });
2929+assert.sameValue(result.includes(output11), true, `output for hourCycle: h11 should include ${output11}`);
3030+3131+result = item.toLocaleString("en", { hourCycle: "h12", timeZone: "UTC" });
3232+assert.sameValue(result.includes(output12), true, `output for hourCycle: h12 should include ${output12}`);
···11+// Copyright (C) 2025 Igalia, S.L. All rights reserved.
22+// This code is governed by the BSD license found in the LICENSE file.
33+44+/*---
55+esid: sec-temporal.zoneddatetime.prototype.tolocalestring
66+description: Hour cycle should be correctly set when defaults are used
77+features: [Temporal]
88+---*/
99+1010+const output0 = "00:00:00";
1111+const output11 = "0:00:00";
1212+const output12 = "12:00:00";
1313+const output24 = "24:00:00";
1414+1515+const item = new Temporal.ZonedDateTime(0n, "UTC");
1616+var result = item.toLocaleString("en", { hour12: false });
1717+assert.sameValue(result.includes(output0), true, `output for hour12: false should include ${output0}`);
1818+1919+result = item.toLocaleString("en", { hour12: true });
2020+assert.sameValue(result.includes(output12), true, `output for hour12: true should include ${output12}`);
2121+2222+result = item.toLocaleString("en", { hourCycle: "h23" });
2323+assert.sameValue(result.includes(output0), true, `output for hourCycle: h23 should include ${output0}`);
2424+2525+result = item.toLocaleString("en", { hourCycle: "h24" });
2626+assert.sameValue(result.includes(output24), true, `output for hourCycle: h24 should include ${output24}`);
2727+2828+result = item.toLocaleString("en", { hourCycle: "h11" });
2929+assert.sameValue(result.includes(output11), true, `output for hourCycle: h11 should include ${output11}`);
3030+3131+result = item.toLocaleString("en", { hourCycle: "h12" });
3232+assert.sameValue(result.includes(output12), true, `output for hourCycle: h12 should include ${output12}`);