[bugs] [PATCH] DST: fix date_change() thoroughly

Explicit setting of Daylight Saving Time should be avoided before as well as
after the mktime() call.

Signed-off-by: Lars Henriksen <LarsHenriksen@xxxxxxxxxx>
---
A better patch that replaces the previous two ("DST: fix date_change()" and
"DST: fix get_first_day()").

 src/utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/utils.c b/src/utils.c
index 8a8de75..a9a9e68 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -525,10 +525,11 @@ int date_change(struct tm *date, int delta_month, int delta_day)
 	t = *date;
 	t.tm_mon += delta_month;
 	t.tm_mday += delta_day;
-
+	t.tm_isdst = -1;
 	if (mktime(&t) == -1) {
 		return 1;
 	} else {
+		t.tm_isdst = -1;
 		*date = t;
 		return 0;
 	}
-- 
2.17.0

Links