1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:57:45 +00:00

AK+LibC+Kernel: Have fewer implementations of year_to_days_in_epoch

I believe the implementation in RTC.cpp had an off-by-one
in the year passed to is_leap_year(). If that's true, then this
fixes that too.
This commit is contained in:
Nico Weber 2020-08-25 16:53:36 -04:00 committed by Andreas Kling
parent 84ed257959
commit 9b17082899
3 changed files with 13 additions and 18 deletions

View file

@ -116,11 +116,7 @@ static time_t tm_to_time(struct tm* tm, long timezone_adjust_seconds)
tm->tm_mon += 12;
}
int days = 0;
for (int year = 70; year < tm->tm_year; ++year)
days += 365 + is_leap_year(1900 + year);
for (int year = tm->tm_year; year < 70; ++year)
days -= 365 + is_leap_year(1900 + year);
int days = years_to_days_since_epoch(1900 + tm->tm_year);
tm->tm_yday = tm->tm_mday - 1;
for (int month = 0; month < tm->tm_mon; ++month)