staticlibs / ccronexpr

Cron expression parsing in ANSI C
Apache License 2.0
150 stars 78 forks source link

CRON_USE_LOCAL_TIME: use DST offsets #20

Closed msantos closed 5 years ago

msantos commented 5 years ago

mktime(3) will automatically account for daylight savings time offsets if the tm_isdst field of the struct tm is set to -1:

http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
tm.tm_isdst = -1;      /* Not set by strptime(); tells mktime()
                          to determine whether daylight saving time
                          is in effect */

ctime(3) also mentions:

tm_isdst A flag that indicates whether daylight saving time is in
         effect at the time described. The value is positive if daylight
         saving time is in effect, zero if it is not, and negative if the
         information is not available.

Fixes https://github.com/staticlibs/ccronexpr/issues/15

msantos commented 5 years ago

This bug caused some problems yesterday. The tests fail when using CRON_USE_LOCAL_TIME so I didn't add a test case.

staticlibs commented 5 years ago

Thanks! Merged.