mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:37:34 +00:00
LibJS: Implement Temporal.PlainDate.prototype.toPlainMonthDay()
This commit is contained in:
parent
31f65b8c50
commit
795e077eb8
6 changed files with 76 additions and 0 deletions
|
@ -447,6 +447,36 @@ PlainYearMonth* year_month_from_fields(GlobalObject& global_object, Object& cale
|
|||
return static_cast<PlainYearMonth*>(year_month_object);
|
||||
}
|
||||
|
||||
// 12.1.26 MonthDayFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-monthdayfromfields
|
||||
PlainMonthDay* month_day_from_fields(GlobalObject& global_object, Object& calendar, Object& fields, Object* options)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. Assert: Type(calendar) is Object.
|
||||
// 2. Assert: Type(fields) is Object.
|
||||
// 3. If options is not present, then
|
||||
// a. Set options to undefined.
|
||||
// 4. Else,
|
||||
// a. Assert: Type(options) is Object.
|
||||
|
||||
// 5. Let monthDay be ? Invoke(calendar, "monthDayFromFields", « fields, options »).
|
||||
auto month_day = Value(&calendar).invoke(global_object, vm.names.monthDayFromFields, &fields, options ?: js_undefined());
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
// 6. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day_object = month_day.to_object(global_object);
|
||||
if (!month_day_object)
|
||||
return {};
|
||||
if (!is<PlainMonthDay>(month_day_object)) {
|
||||
vm.throw_exception<TypeError>(global_object, ErrorType::NotA, "Temporal.PlainMonthDay");
|
||||
return {};
|
||||
}
|
||||
|
||||
// 7. Return monthDay.
|
||||
return static_cast<PlainMonthDay*>(month_day_object);
|
||||
}
|
||||
|
||||
// 12.1.28 CalendarEquals ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal-calendarequals
|
||||
bool calendar_equals(GlobalObject& global_object, Object& one, Object& two)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue