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

LibJS: Implement Temporal.ZonedDateTime.prototype.equals

This commit is contained in:
Luke Wilde 2021-11-07 01:20:00 +00:00 committed by Idan Horowitz
parent ac12581140
commit 706296374b
5 changed files with 70 additions and 0 deletions

View file

@ -646,4 +646,25 @@ ThrowCompletionOr<MarkedValueList> get_possible_instants_for(GlobalObject& globa
return { move(list) };
}
// 11.6.18 TimeZoneEquals ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal-timezoneequals
ThrowCompletionOr<bool> time_zone_equals(GlobalObject& global_object, Object& one, Object& two)
{
// 1. If one and two are the same Object value, return true.
if (&one == &two)
return true;
// 2. Let timeZoneOne be ? ToString(one).
auto time_zone_one = TRY(Value(&one).to_string(global_object));
// 3. Let timeZoneTwo be ? ToString(two).
auto time_zone_two = TRY(Value(&two).to_string(global_object));
// 4. If timeZoneOne is timeZoneTwo, return true.
if (time_zone_one == time_zone_two)
return true;
// 5. Return false.
return false;
}
}