From 42c22539a3970395ebfd6c0f306ca18624089293 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Mon, 12 Apr 2021 17:03:36 +0200 Subject: schedule: fix daylight saving problem with mktime() mktime modifies the struct tm it receives and takes into account whether DST is active or not (tm_isdst). tm_isdst == 0 adjusts the time, which causes the time mismatch error. All fields are being initialized to 0 and therefore it is assumed that the time that has been passed is not in daylight saving time. When the value is negative in tm.tm_isdst it delegates to mktime to guess if it is in daylight saving time or not, this works 99% of the time. Best way would be that ogserver knows what is its timezone and when daylight saving applies, so tm_isdst is set to 0 or 1 accordingly. Meanwhile, "tm_isdst = -1" provides the hotfix. --- src/schedule.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/schedule.c b/src/schedule.c index 9fb272c..890a8ce 100644 --- a/src/schedule.c +++ b/src/schedule.c @@ -242,6 +242,7 @@ static void og_schedule_create_weekdays(int month, int year, tm.tm_mday = month_days[k]; tm.tm_hour = hours[l] - 1; tm.tm_min = minutes; + tm.tm_isdst = -1; seconds = mktime(&tm); if (check_stale && og_schedule_stale(seconds)) @@ -298,6 +299,7 @@ static void og_schedule_create_weeks(int month, int year, tm.tm_mday = month_days[k]; tm.tm_hour = hours[l] - 1; tm.tm_min = minutes; + tm.tm_isdst = -1; seconds = mktime(&tm); if (check_stale && og_schedule_stale(seconds)) @@ -337,6 +339,7 @@ static void og_schedule_create_days(int month, int year, tm.tm_mday = days[k]; tm.tm_hour = hours[l] - 1; tm.tm_min = minutes; + tm.tm_isdst = -1; seconds = mktime(&tm); if (check_stale && og_schedule_stale(seconds)) -- cgit v1.2.3-18-g5258