aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-09-18 19:25:40 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-09-18 19:25:40 +0200
commitf959a3d1e1928995b717c8e75058dfd1ae21b3ad (patch)
tree6f5d2a7051022c69b5d2d498bb3572896ea6f7d1
parent54caf567355d9862218b5e182d169910cd183e2c (diff)
downloadglutte-o-matic-f959a3d1e1928995b717c8e75058dfd1ae21b3ad.tar.gz
glutte-o-matic-f959a3d1e1928995b717c8e75058dfd1ae21b3ad.tar.bz2
glutte-o-matic-f959a3d1e1928995b717c8e75058dfd1ae21b3ad.zip
Handle failing is_dst properly and output error
-rw-r--r--src/common/src/Core/common.c17
1 files changed, 14 insertions, 3 deletions
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;
}