From 3166857843a2c872700e385f37002bbab3f85a0b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 25 Aug 2018 19:16:08 +0100 Subject: [PATCH] setdate: Fix bugs in BCD mode With these fixed it now works correctly against the DS1302 --- Applications/util/setdate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; -- 2.34.1