aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-lib.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2018-02-28 16:50:53 -0500
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-03-17 09:20:50 -0400
commitf18046c50d2bb726538a83dfb035bfa592779e9c (patch)
tree7ec9f12b2c45b77103ba609e67e2eef2741a0110 /drivers/rtc/rtc-lib.c
parent561f8281cf90051bc5f11017ac5ebb21eec45ad9 (diff)
rtc: fix rtc_time64_to_tm for 3477
The current correction for leap years will fail in 3477. 3476-12-31 being 3477-01-00 because this is 366 leap years after 1970 and 3477 isn't a leap year. Fix that by looping over until days is positive or zero. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-lib.c')
-rw-r--r--drivers/rtc/rtc-lib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index ad5bb21908e5..4a3c0f3aab14 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -65,7 +65,7 @@ void rtc_time64_to_tm(time64_t time, struct rtc_time *tm)
65 days -= (year - 1970) * 365 65 days -= (year - 1970) * 365
66 + LEAPS_THRU_END_OF(year - 1) 66 + LEAPS_THRU_END_OF(year - 1)
67 - LEAPS_THRU_END_OF(1970 - 1); 67 - LEAPS_THRU_END_OF(1970 - 1);
68 if (days < 0) { 68 while (days < 0) {
69 year -= 1; 69 year -= 1;
70 days += 365 + is_leap_year(year); 70 days += 365 + is_leap_year(year);
71 } 71 }