diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2021-04-12 17:03:36 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-04-12 17:08:00 +0200 |
commit | 42c22539a3970395ebfd6c0f306ca18624089293 (patch) | |
tree | e6caba05bf820455b6c8474228de32f9f3f70653 /src | |
parent | 0212091e7fa0b58f353a05cfc671bd544e08e07e (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/schedule.c | 3 |
1 files changed, 3 insertions, 0 deletions
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)) |