mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:37:36 +00:00
LibJS: Implement Date's TimeClip AO
This commit is contained in:
parent
b76e44f66f
commit
e56be34148
2 changed files with 16 additions and 0 deletions
|
@ -389,4 +389,19 @@ Value make_date(Value day, Value time)
|
|||
return tv;
|
||||
}
|
||||
|
||||
// 21.4.1.14 TimeClip ( time ), https://tc39.es/ecma262/#sec-timeclip
|
||||
Value time_clip(GlobalObject& global_object, Value time)
|
||||
{
|
||||
// 1. If time is not finite, return NaN.
|
||||
if (!time.is_finite_number())
|
||||
return js_nan();
|
||||
|
||||
// 2. If abs(ℝ(time)) > 8.64 × 10^15, return NaN.
|
||||
if (fabs(time.as_double()) > 8.64E15)
|
||||
return js_nan();
|
||||
|
||||
// 3. Return 𝔽(! ToIntegerOrInfinity(time)).
|
||||
return Value(MUST(time.to_integer_or_infinity(global_object)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -102,5 +102,6 @@ double day(double);
|
|||
Value make_time(GlobalObject& global_object, Value hour, Value min, Value sec, Value ms);
|
||||
Value make_day(GlobalObject& global_object, Value year, Value month, Value date);
|
||||
Value make_date(Value day, Value time);
|
||||
Value time_clip(GlobalObject& global_object, Value time);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue