From bf4977e41b02f0ce79fff7280032431d184a0c90 Mon Sep 17 00:00:00 2001 From: Christopher Friedt Date: Wed, 21 Jun 2023 04:13:15 -0400 Subject: [PATCH] drivers: rtc: mc146818: changes for y2k test The year needs to be corrected to an offset from 1900. Signed-off-by: Christopher Friedt --- drivers/rtc/rtc_mc146818.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc_mc146818.c b/drivers/rtc/rtc_mc146818.c index 58177b10c86..f34b76d66a1 100644 --- a/drivers/rtc/rtc_mc146818.c +++ b/drivers/rtc/rtc_mc146818.c @@ -191,8 +191,8 @@ static int rtc_mc146818_set_time(const struct device *dev, const struct rtc_time value = rtc_read(RTC_DATA); rtc_write(RTC_DATA, value | RTC_UCI_BIT); - year = (1970 + timeptr->tm_year) % 100; - cent = (1970 + timeptr->tm_year) / 100; + year = (1900 + timeptr->tm_year) % 100; + cent = (1900 + timeptr->tm_year) / 100; if (!(rtc_read(RTC_DATA) & RTC_DMODE_BIT)) { rtc_write(RTC_SEC, (uint8_t)bin2bcd(timeptr->tm_sec)); @@ -271,7 +271,7 @@ static int rtc_mc146818_get_time(const struct device *dev, struct rtc_time *tim timeptr->tm_sec = bcd2bin(timeptr->tm_sec); } - timeptr->tm_year = 100 * (int)cent + year - 1970; + timeptr->tm_year = 100 * (int)cent + year - 1900; timeptr->tm_nsec = 0; timeptr->tm_yday = 0;