From 179219621986c189b183bd9b668afa9f04a46af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Tue, 1 Aug 2017 11:49:43 +0200 Subject: [PATCH] application: fix month handling --- application.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application.c b/application.c index ab0e433..dc0d56b 100644 --- a/application.c +++ b/application.c @@ -143,14 +143,14 @@ static void process_command(char* str) if (!word) { time_rtc = rtc_get_counter_val(); // get time from internal RTC time_tm = localtime(&time_rtc); // convert time - printf("date: %d-%02d-%02d\n", 1900+time_tm->tm_year, time_tm->tm_mon, time_tm->tm_mday); + printf("date: %d-%02d-%02d\n", 1900+time_tm->tm_year, time_tm->tm_mon+1, time_tm->tm_mday); } else if (strlen(word)!=10 || word[0]!='2' || word[1]!='0' || word[2]<'0' || word[2]>'9' || word[3]<'0' || word[3]>'9' || word[5]<'0' || word[5]>'1' || word[6]<'0' || word[6]>'9' || word[8]<'0' || word[8]>'3' || word[9]<'0' || word[9]>'9') { goto error; } else { time_rtc = rtc_get_counter_val(); // get time from internal RTC time_tm = localtime(&time_rtc); // convert time time_tm->tm_year = ((word[0]-'0')*1000+(word[1]-'0')*100+(word[2]-'0')*10+(word[3]-'0')*1)-1900; // set year - time_tm->tm_mon = (word[5]-'0')*10+(word[6]-'0')*1; // set month + time_tm->tm_mon = (word[5]-'0')*10+(word[6]-'0')*1-1; // set month time_tm->tm_mday = (word[8]-'0')*10+(word[9]-'0')*1; // set day time_rtc = mktime(time_tm); // get back seconds rtc_set_counter_val(time_rtc); // save time to internal RTC @@ -214,7 +214,7 @@ void main(void) time_rtc= rtc_get_counter_val(); // get time from internal RTC time_tm = localtime(&time_rtc); // convert time - printf("date: %d-%02d-%02d %02d:%02d:%02d\n", 1900+time_tm->tm_year, time_tm->tm_mon, time_tm->tm_mday, time_tm->tm_hour, time_tm->tm_min, time_tm->tm_sec); + printf("date: %d-%02d-%02d %02d:%02d:%02d\n", 1900+time_tm->tm_year, time_tm->tm_mon+1, time_tm->tm_mday, time_tm->tm_hour, time_tm->tm_min, time_tm->tm_sec); // main loop printf("command input: ready\n");