From 363cc121462e452236623db44845329db3098fca Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Mon, 2 Jan 2023 19:51:15 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"LibJS:=20Implement=20MakeDay=20withou?= =?UTF-8?q?t=20using=20AK::years=5Fto=5Fdays=5Fsince=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 032664332be6e1d42567165e9ffb623faf2b9a10. Now that AK::years_to_days_since_epoch has acceptable performance, we can go back to the "easy" way of computing the unix epoch time. --- Userland/Libraries/LibJS/Runtime/Date.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index 4c4db3ee14..27ee92e872 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -482,10 +482,7 @@ double make_day(double year, double month, double date) // 8. Find a finite time value t such that YearFromTime(t) is ym and MonthFromTime(t) is mn and DateFromTime(t) is 1𝔽; but if this is not possible (because some argument is out of range), return NaN. if (!AK::is_within_range(ym) || !AK::is_within_range(mn + 1)) return NAN; - - // FIXME: We are avoiding AK::years_to_days_since_epoch here because it is implemented by looping over - // the range [1970, ym), which will spin for any time value with an extremely large year. - auto t = time_from_year(ym) + (day_of_year(static_cast(ym), static_cast(mn) + 1, 1) * ms_per_day); + auto t = days_since_epoch(static_cast(ym), static_cast(mn) + 1, 1) * ms_per_day; // 9. Return Day(t) + dt - 1𝔽. return day(static_cast(t)) + dt - 1;