From: Alan Cox Date: Sat, 25 Aug 2018 18:16:08 +0000 (+0100) Subject: setdate: Fix bugs in BCD mode X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3166857843a2c872700e385f37002bbab3f85a0b;p=FUZIX.git setdate: Fix bugs in BCD mode With these fixed it now works correctly against the DS1302 --- diff --git a/Applications/util/setdate.c b/Applications/util/setdate.c index c61cdca7..9fd82838 100644 --- a/Applications/util/setdate.c +++ b/Applications/util/setdate.c @@ -121,8 +121,9 @@ int rtcdate(void) p = rtc.data.bytes; for (i = 0; i < 7; i++) unbc(p++); + p = rtc.data.bytes; /* The date is now effectively encoded in Binary Coded Hundreds */ - tm.tm_year = (*p * 100) + p[1]; + tm.tm_year = ((*p * 100) + p[1]) - 1900; /* Fall through */ case CMOS_RTC_DEC: p = rtc.data.bytes; @@ -159,7 +160,7 @@ int main(int argc, char *argv[]) time_t t; char newval[128]; int y,m,d,h,s; - int set; + int set = 0; int opt; int user = 0, autom = 0;