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

LibJS: Add Temporal.Instant.compare()

This commit is contained in:
Idan Horowitz 2021-07-11 21:18:48 +03:00 committed by Linus Groh
parent b816037739
commit 33cf6274e8
6 changed files with 49 additions and 0 deletions

View file

@ -138,4 +138,19 @@ BigInt* parse_temporal_instant(GlobalObject& global_object, String const& iso_st
return js_bigint(vm.heap(), utc->big_integer().minus(Crypto::SignedBigInteger::create_from(offset_nanoseconds)));
}
// 8.5.5 CompareEpochNanoseconds ( epochNanosecondsOne, epochNanosecondsTwo )
i32 compare_epoch_nanoseconds(BigInt const& epoch_nanoseconds_one, BigInt const& epoch_nanoseconds_two)
{
// 1. If epochNanosecondsOne > epochNanosecondsTwo, return 1.
if (epoch_nanoseconds_one.big_integer() > epoch_nanoseconds_two.big_integer())
return 1;
// 2. If epochNanosecondsOne < epochNanosecondsTwo, return -1.
if (epoch_nanoseconds_one.big_integer() < epoch_nanoseconds_two.big_integer())
return -1;
// 3. Return 0.
return 0;
}
}