diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp index 8eee6d9796..f38d9d0df5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp @@ -187,8 +187,8 @@ ThrowCompletionOr temporal_month_day_to_string(GlobalObject& global_obje // 6. Let calendarID be ? ToString(monthDay.[[Calendar]]). auto calendar_id = TRY(Value(&month_day.calendar()).to_string(global_object)); - // 7. If calendarID is not "iso8601", then - if (calendar_id != "iso8601"sv) { + // 7. If showCalendar is "always" or if calendarID is not "iso8601", then + if (show_calendar == "always"sv || calendar_id != "iso8601"sv) { // a. Let year be ! PadISOYear(monthDay.[[ISOYear]]). // b. Set result to the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), and result. result = String::formatted("{}-{}", pad_iso_year(month_day.iso_year()), result); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp index 487f6a27c9..f122784630 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp @@ -245,8 +245,8 @@ ThrowCompletionOr temporal_year_month_to_string(GlobalObject& global_obj // 6. Let calendarID be ? ToString(yearMonth.[[Calendar]]). auto calendar_id = TRY(Value(&year_month.calendar()).to_string(global_object)); - // 7. If calendarID is not "iso8601", then - if (calendar_id != "iso8601") { + // 7. If showCalendar is "always" or if calendarID is not "iso8601", then + if (show_calendar == "always"sv || calendar_id != "iso8601") { // a. Let day be yearMonth.[[ISODay]] formatted as a two-digit decimal number, padded to the left with a zero if necessary. // b. Set result to the string-concatenation of result, the code unit 0x002D (HYPHEN-MINUS), and day. result = String::formatted("{}-{:02}", result, year_month.iso_day()); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.prototype.toString.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.prototype.toString.js index 8a1c4b1da2..fa70d2e4fa 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.prototype.toString.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.prototype.toString.js @@ -9,7 +9,7 @@ describe("correct behavior", () => { plainMonthDay = new Temporal.PlainMonthDay(7, 6); expect(plainMonthDay.toString()).toBe("07-06"); expect(plainMonthDay.toString({ calendarName: "auto" })).toBe("07-06"); - expect(plainMonthDay.toString({ calendarName: "always" })).toBe("07-06[u-ca=iso8601]"); + expect(plainMonthDay.toString({ calendarName: "always" })).toBe("1972-07-06[u-ca=iso8601]"); expect(plainMonthDay.toString({ calendarName: "never" })).toBe("07-06"); plainMonthDay = new Temporal.PlainMonthDay(7, 6, { toString: () => "foo" }, 2021); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainYearMonth/PlainYearMonth.prototype.toString.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainYearMonth/PlainYearMonth.prototype.toString.js index ef7b6433cb..2be37729d9 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainYearMonth/PlainYearMonth.prototype.toString.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainYearMonth/PlainYearMonth.prototype.toString.js @@ -9,7 +9,9 @@ describe("correct behavior", () => { plainYearMonth = new Temporal.PlainYearMonth(2021, 7); expect(plainYearMonth.toString()).toBe("2021-07"); expect(plainYearMonth.toString({ calendarName: "auto" })).toBe("2021-07"); - expect(plainYearMonth.toString({ calendarName: "always" })).toBe("2021-07[u-ca=iso8601]"); + expect(plainYearMonth.toString({ calendarName: "always" })).toBe( + "2021-07-01[u-ca=iso8601]" + ); expect(plainYearMonth.toString({ calendarName: "never" })).toBe("2021-07"); plainYearMonth = new Temporal.PlainYearMonth(2021, 7, { toString: () => "foo" }, 6);