LibJS+LibUnicode: Always format zoned minutes and seconds with 2 digits

This matches the behavior of other engines.
This commit is contained in:
Timothy Flynn 2026-03-08 17:37:06 -04:00 committed by Jelle Raaijmakers
parent 544e6ee3bb
commit 49b09b3fbe
2 changed files with 3 additions and 3 deletions

View file

@ -304,7 +304,7 @@ String CalendarPattern::to_pattern() const
if (minute.has_value()) {
switch (*minute) {
case CalendarPatternStyle::Numeric:
builder.append("m"sv);
builder.append(time_zone_name.has_value() ? "mm"sv : "m"sv);
break;
case CalendarPatternStyle::TwoDigit:
builder.append("mm"sv);
@ -316,7 +316,7 @@ String CalendarPattern::to_pattern() const
if (second.has_value()) {
switch (*second) {
case CalendarPatternStyle::Numeric:
builder.append("s"sv);
builder.append(time_zone_name.has_value() ? "ss"sv : "s"sv);
break;
case CalendarPatternStyle::TwoDigit:
builder.append("ss"sv);

View file

@ -6,7 +6,7 @@ describe("correct behavior", () => {
test("basic functionality", () => {
const plainDateTime = new Temporal.PlainDateTime(2021, 11, 3, 1, 33, 5, 100, 200, 300, "gregory");
const zonedDateTime = plainDateTime.toZonedDateTime("UTC");
expect(zonedDateTime.toLocaleString()).toBe("11/3/2021, 1:33:5 AM UTC");
expect(zonedDateTime.toLocaleString()).toBe("11/3/2021, 1:33:05 AM UTC");
});
});