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 /Kernel/RTC.cpp | |
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 'Kernel/RTC.cpp')
-rw-r--r-- | Kernel/RTC.cpp | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/Kernel/RTC.cpp b/Kernel/RTC.cpp index d2944f7100..25f494bd98 100644 --- a/Kernel/RTC.cpp +++ b/Kernel/RTC.cpp @@ -93,18 +93,6 @@ static unsigned days_in_months_since_start_of_year(unsigned month, unsigned year return days; } -static unsigned days_in_years_since_epoch(unsigned year) -{ - unsigned days = 0; - while (year > 1969) { - days += 365; - if (is_leap_year(year)) - ++days; - --year; - } - return days; -} - static u8 bcd_to_binary(u8 bcd) { return (bcd & 0x0F) + ((bcd >> 4) * 10); @@ -160,7 +148,7 @@ time_t now() ASSERT(year >= 2018); - return days_in_years_since_epoch(year - 1) * 86400 + return years_to_days_since_epoch(year) * 86400 + days_in_months_since_start_of_year(month - 1, year) * 86400 + (day - 1) * 86400 + hour * 3600 |