diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/src/Core/common.c | 8 | ||||
-rw-r--r-- | src/common/src/Core/main.c | 6 | ||||
-rw-r--r-- | src/common/src/GPS/gps.c | 3 |
3 files changed, 5 insertions, 12 deletions
diff --git a/src/common/src/Core/common.c b/src/common/src/Core/common.c index 3102e81..7af361f 100644 --- a/src/common/src/Core/common.c +++ b/src/common/src/Core/common.c @@ -135,7 +135,7 @@ int local_time(struct tm *time) { if (dst == -1) { usart_debug("mktime fail for dst %d-%d-%d %d:%d:%d " "dst %d wday %d yday %d\r\n", - time->tm_year, time->tm_mon + 1, time->tm_mday, + time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec, time->tm_isdst, time->tm_wday, time->tm_yday); } @@ -144,15 +144,11 @@ int local_time(struct tm *time) { time->tm_isdst = 1; } -#ifdef SIMULATOR - time->tm_year -= 1900; -#endif - // Let mktime fix the struct tm *time if (mktime(time) == (time_t)-1) { usart_debug("mktime fail for local_time %d-%d-%d %d:%d:%d " "dst %d wday %d yday %d\r\n", - time->tm_year, time->tm_mon + 1, time->tm_mday, + time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec, time->tm_isdst, time->tm_wday, time->tm_yday); valid = 0; diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c index f9c1a08..481e686 100644 --- a/src/common/src/Core/main.c +++ b/src/common/src/Core/main.c @@ -411,7 +411,7 @@ static void gps_monit_task(void __attribute__ ((unused))*pvParameters) { if (time.tm_sec % 30 == 0 && t_gps_print_latch == 0) { usart_debug("T_GPS %04d-%02d-%02d %02d:%02d:%02d %d SV tracked\r\n", - gps_time.tm_year, gps_time.tm_mon + 1, gps_time.tm_mday, + gps_time.tm_year + 1900, gps_time.tm_mon + 1, gps_time.tm_mday, gps_time.tm_hour, gps_time.tm_min, gps_time.tm_sec, num_sv_used); @@ -425,11 +425,7 @@ static void gps_monit_task(void __attribute__ ((unused))*pvParameters) { } usart_debug("TIME %04d-%02d-%02d %02d:%02d:%02d [%s]\r\n", -#ifdef SIMULATOR time.tm_year + 1900, -#else - time.tm_year, -#endif time.tm_mon + 1, time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec, mode); diff --git a/src/common/src/GPS/gps.c b/src/common/src/GPS/gps.c index 1db92cb..bfdc1c1 100644 --- a/src/common/src/GPS/gps.c +++ b/src/common/src/GPS/gps.c @@ -86,7 +86,8 @@ static void gps_task(void __attribute__ ((unused))*pvParameters) { struct minmea_sentence_rmc frame; if (minmea_parse_rmc(&frame, rxbuf)) { xSemaphoreTake(timeutc_semaphore, portMAX_DELAY); - gps_timeutc.tm_year = 2000 + frame.date.year; + // tm_year is saved as Year - 1900 in struct tm + gps_timeutc.tm_year = 2000 + frame.date.year - 1900; // struct tm months are zero-indexed gps_timeutc.tm_mon = frame.date.month - 1; gps_timeutc.tm_mday = frame.date.day; |