mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:37:35 +00:00
LibJS: Port temporal_date_to_string() to String
This commit is contained in:
parent
453d3063f5
commit
921ef7273e
2 changed files with 5 additions and 5 deletions
|
@ -414,7 +414,7 @@ ThrowCompletionOr<String> pad_iso_year(VM& vm, i32 y)
|
|||
}
|
||||
|
||||
// 3.5.8 TemporalDateToString ( temporalDate, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporaldatetostring
|
||||
ThrowCompletionOr<DeprecatedString> temporal_date_to_string(VM& vm, PlainDate& temporal_date, StringView show_calendar)
|
||||
ThrowCompletionOr<String> temporal_date_to_string(VM& vm, PlainDate& temporal_date, StringView show_calendar)
|
||||
{
|
||||
// 1. Assert: Type(temporalDate) is Object.
|
||||
// 2. Assert: temporalDate has an [[InitializedTemporalDate]] internal slot.
|
||||
|
@ -423,16 +423,16 @@ ThrowCompletionOr<DeprecatedString> temporal_date_to_string(VM& vm, PlainDate& t
|
|||
auto year = MUST_OR_THROW_OOM(pad_iso_year(vm, temporal_date.iso_year()));
|
||||
|
||||
// 4. Let month be ToZeroPaddedDecimalString(monthDay.[[ISOMonth]], 2).
|
||||
auto month = DeprecatedString::formatted("{:02}", temporal_date.iso_month());
|
||||
auto month = TRY_OR_THROW_OOM(vm, String::formatted("{:02}", temporal_date.iso_month()));
|
||||
|
||||
// 5. Let day be ToZeroPaddedDecimalString(monthDay.[[ISODay]], 2).
|
||||
auto day = DeprecatedString::formatted("{:02}", temporal_date.iso_day());
|
||||
auto day = TRY_OR_THROW_OOM(vm, String::formatted("{:02}", temporal_date.iso_day()));
|
||||
|
||||
// 6. Let calendar be ? MaybeFormatCalendarAnnotation(temporalDate.[[Calendar]], showCalendar).
|
||||
auto calendar = TRY(maybe_format_calendar_annotation(vm, &temporal_date.calendar(), show_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 DeprecatedString::formatted("{}-{}-{}{}", year, month, day, calendar);
|
||||
return TRY_OR_THROW_OOM(vm, String::formatted("{}-{}-{}{}", year, month, day, calendar));
|
||||
}
|
||||
|
||||
// 3.5.9 AddISODate ( year, month, day, years, months, weeks, days, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-addisodate
|
||||
|
|
|
@ -53,7 +53,7 @@ ThrowCompletionOr<ISODateRecord> regulate_iso_date(VM&, double year, double mont
|
|||
bool is_valid_iso_date(i32 year, u8 month, u8 day);
|
||||
ISODateRecord balance_iso_date(double year, double month, double day);
|
||||
ThrowCompletionOr<String> pad_iso_year(VM&, i32 y);
|
||||
ThrowCompletionOr<DeprecatedString> temporal_date_to_string(VM&, PlainDate&, StringView show_calendar);
|
||||
ThrowCompletionOr<String> temporal_date_to_string(VM&, PlainDate&, StringView show_calendar);
|
||||
ThrowCompletionOr<ISODateRecord> add_iso_date(VM&, i32 year, u8 month, u8 day, double years, double months, double weeks, double days, StringView overflow);
|
||||
i8 compare_iso_date(i32 year1, u8 month1, u8 day1, i32 year2, u8 month2, u8 day2);
|
||||
ThrowCompletionOr<Duration*> difference_temporal_plain_date(VM&, DifferenceOperation, PlainDate&, Value other, Value options);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue