From f959a3d1e1928995b717c8e75058dfd1ae21b3ad Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 18 Sep 2016 19:25:40 +0200 Subject: Handle failing is_dst properly and output error --- src/common/src/Core/common.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/common/src/Core/common.c b/src/common/src/Core/common.c index b980985..710a53f 100644 --- a/src/common/src/Core/common.c +++ b/src/common/src/Core/common.c @@ -60,7 +60,6 @@ int find_last_sunday(const struct tm* time) { while (t.tm_mon == time->tm_mon) { t.tm_mday++; if (mktime(&t) == (time_t)-1) { - // TODO error return -1; } @@ -132,7 +131,15 @@ int local_time(struct tm *time) { if (valid) { time->tm_hour += local_time_offset; - if (is_dst(time)) { + const int dst = is_dst(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, time->tm_mday, + time->tm_hour, time->tm_min, time->tm_sec, + time->tm_isdst, time->tm_wday, time->tm_yday); + } + else if (dst == 1) { time->tm_hour++; time->tm_isdst = 1; } @@ -143,7 +150,11 @@ int local_time(struct tm *time) { // Let mktime fix the struct tm *time if (mktime(time) == (time_t)-1) { - // TODO inform about failure + 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, time->tm_mday, + time->tm_hour, time->tm_min, time->tm_sec, + time->tm_isdst, time->tm_wday, time->tm_yday); valid = 0; } -- cgit v1.2.3