diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index 152870d0f6..484191ff5d 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -5,6 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -147,6 +148,8 @@ double time_from_year(i32 y) i32 year_from_time(double t) { // the largest integral Number y (closest to +∞) such that TimeFromYear(y) ≤ t + if (!Value(t).is_finite_number()) + return NumericLimits::max(); // Approximation using average number of milliseconds per year. We might have to adjust this guess afterwards. auto year = static_cast(t / (365.2425 * Date::ms_per_day) + 1970);