mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 11:00:29 +00:00
LibJS: Protect DayWithinYear against non-finite times
This commit is contained in:
parent
9be0a0fd28
commit
4848f587cd
Notes:
sideshowbarker
2024-07-17 20:47:31 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/4848f587cd6 Pull-request: https://github.com/SerenityOS/serenity/pull/11930 Reviewed-by: https://github.com/linusg ✅
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…
Reference in a new issue