From: Alan Cox Date: Wed, 11 Jul 2018 22:22:12 +0000 (+0100) Subject: setdate: fix year in BCD mode X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d5b529bc28c8ec78433651b1b38053ed84da215d;p=FUZIX.git setdate: fix year in BCD mode --- diff --git a/Applications/util/setdate.c b/Applications/util/setdate.c index 30748b58..c61cdca7 100644 --- a/Applications/util/setdate.c +++ b/Applications/util/setdate.c @@ -121,9 +121,13 @@ int rtcdate(void) p = rtc.data.bytes; for (i = 0; i < 7; i++) unbc(p++); + /* The date is now effectively encoded in Binary Coded Hundreds */ + tm.tm_year = (*p * 100) + p[1]; + /* Fall through */ case CMOS_RTC_DEC: p = rtc.data.bytes; - tm.tm_year = (*p + (p[1] << 8)) - 1900; + if (rtc.type != CMOS_RTC_BCD) + tm.tm_year = (*p + (p[1] << 8)) - 1900; p += 2; tm.tm_mon = *p++; tm.tm_mday = *p++;