mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibJS: Protect DayWithinYear against non-finite times
This commit is contained in:
parent
9be0a0fd28
commit
4848f587cd
1 changed files with 3 additions and 0 deletions
|
@ -63,6 +63,9 @@ String Date::iso_date_string() const
|
|||
// DayWithinYear(t), https://tc39.es/ecma262/#eqn-DayWithinYear
|
||||
u16 day_within_year(double t)
|
||||
{
|
||||
if (!Value(t).is_finite_number())
|
||||
return 0;
|
||||
|
||||
// Day(t) - DayFromYear(YearFromTime(t))
|
||||
return static_cast<u16>(day(t) - day_from_year(year_from_time(t)));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue