mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Revert "LibJS: Implement MakeDay without using AK::years_to_days_since…"
This reverts commit 032664332b
.
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.
This commit is contained in:
parent
3334cf675a
commit
363cc12146
1 changed files with 1 additions and 4 deletions
|
@ -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<int>(ym) || !AK::is_within_range<int>(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<int>(ym), static_cast<int>(mn) + 1, 1) * ms_per_day);
|
||||
auto t = days_since_epoch(static_cast<int>(ym), static_cast<int>(mn) + 1, 1) * ms_per_day;
|
||||
|
||||
// 9. Return Day(t) + dt - 1𝔽.
|
||||
return day(static_cast<double>(t)) + dt - 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue