1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:07:36 +00:00

LibJS: Avoid calling ToString on calendar when calendarName is "never"

This is a normative change in the Temporal spec.

See:
- 6122f4e
- cf586bc
This commit is contained in:
Luke Wilde 2022-08-08 14:48:48 +01:00 committed by Linus Groh
parent 0d7b634313
commit 54bb6bf2c0
8 changed files with 115 additions and 33 deletions

View file

@ -427,13 +427,10 @@ ThrowCompletionOr<String> temporal_date_to_string(VM& vm, PlainDate& temporal_da
// 5. Let day be ToZeroPaddedDecimalString(monthDay.[[ISODay]], 2).
auto day = String::formatted("{:02}", temporal_date.iso_day());
// 6. Let calendarID be ? ToString(temporalDate.[[Calendar]]).
auto calendar_id = TRY(Value(&temporal_date.calendar()).to_string(vm));
// 6. Let calendar be ? MaybeFormatCalendarAnnotation(temporalDate.[[Calendar]], showCalendar).
auto calendar = TRY(maybe_format_calendar_annotation(vm, &temporal_date.calendar(), show_calendar));
// 7. Let calendar be ! FormatCalendarAnnotation(calendarID, showCalendar).
auto calendar = format_calendar_annotation(calendar_id, show_calendar);
// 8. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), day, and calendar.
// 7. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), day, and calendar.
return String::formatted("{}-{}-{}{}", year, month, day, calendar);
}