mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
LibJS: Implement Temporal.PlainDate.prototype.month
This commit is contained in:
parent
3bec18432a
commit
a0af9b11fb
5 changed files with 54 additions and 0 deletions
|
@ -140,6 +140,27 @@ double calendar_year(GlobalObject& global_object, Object& calendar, Object& date
|
|||
return result.to_integer_or_infinity(global_object);
|
||||
}
|
||||
|
||||
// 12.1.10 CalendarMonth ( calendar, dateLike ), https://tc39.es/proposal-temporal/#sec-temporal-calendarmonth
|
||||
double calendar_month(GlobalObject& global_object, Object& calendar, Object& date_like)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
// 1. Assert: Type(calendar) is Object.
|
||||
|
||||
// 2. Let result be ? Invoke(calendar, "month", « dateLike »).
|
||||
auto result = calendar.invoke(vm.names.month, &date_like);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
// 3. If result is undefined, throw a RangeError exception.
|
||||
if (result.is_undefined()) {
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.month.as_string());
|
||||
return {};
|
||||
}
|
||||
|
||||
// 4. Return ? ToPositiveIntegerOrInfinity(result).
|
||||
return to_positive_integer_or_infinity(global_object, result);
|
||||
}
|
||||
|
||||
// 12.1.21 ToTemporalCalendar ( temporalCalendarLike ), https://tc39.es/proposal-temporal/#sec-temporal-totemporalcalendar
|
||||
Object* to_temporal_calendar(GlobalObject& global_object, Value temporal_calendar_like)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue