diff options
author | Nico Weber <thakis@chromium.org> | 2020-08-25 16:53:36 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-26 08:52:07 +0200 |
commit | 9b170828999d1b20da0e1f15c548188f6835a1cb (patch) | |
tree | a23b7dfd7fe93714e89d4b29d20972feec482c0f /Libraries | |
parent | 84ed2579594fdadef29ba145d8a7948ffe26200b (diff) | |
download | serenity-9b170828999d1b20da0e1f15c548188f6835a1cb.zip |
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.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibC/time.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/Libraries/LibC/time.cpp b/Libraries/LibC/time.cpp index fce068699a..7a49ec8a95 100644 --- a/Libraries/LibC/time.cpp +++ b/Libraries/LibC/time.cpp @@ -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) |