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

LibJS: Implement Temporal.PlainDate.prototype.equals & Required AO

This commit is contained in:
Idan Horowitz 2021-07-21 22:21:45 +03:00 committed by Linus Groh
parent cf78efaef5
commit d804ce830d
5 changed files with 69 additions and 0 deletions

View file

@ -231,6 +231,31 @@ PlainDate* date_from_fields(GlobalObject& global_object, Object& calendar, Objec
return static_cast<PlainDate*>(date_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)
{
auto& vm = global_object.vm();
// 1. If one and two are the same Object value, return true.
if (&one == &two)
return true;
// 2. Let calendarOne be ? ToString(one).
auto calendar_one = Value(&one).to_string(global_object);
if (vm.exception())
return {};
// 3. Let calendarTwo be ? ToString(two).
auto calendar_two = Value(&two).to_string(global_object);
if (vm.exception())
return {};
// 4. If calendarOne is calendarTwo, return true.
if (calendar_one == calendar_two)
return true;
// 5. Return false.
return false;
}
// 12.1.30 IsISOLeapYear ( year ), https://tc39.es/proposal-temporal/#sec-temporal-isisoleapyear
bool is_iso_leap_year(i32 year)
{