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.
master
Jose M. Guisado 2021-04-12 17:03:36 +02:00 committed by OpenGnSys Support Team
parent 0212091e7f
commit 42c22539a3
1 changed files with 3 additions and 0 deletions

View File

@ -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))