LibJS: Protect DayWithinYear against non-finite times

This commit is contained in:
Timothy Flynn 2022-01-16 00:54:48 -05:00 committed by Andreas Kling
parent 9be0a0fd28
commit 4848f587cd
Notes: sideshowbarker 2024-07-17 20:47:31 +09:00

View file

@ -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)));
}