Fix for mktime() issue

Albrecht Dreß albrecht.dress at arcor.de
Mon Mar 15 21:10:31 CET 2010


Am 15.03.10 20:42 schrieb(en) Ton Voon:
> This patch was applied to Nagios Core and was in 3.2.0. I've fixed a specific problem last year with timeperiods when DST moved back one hour, but I didn't change the other occurrences of this patch. My feeling was to get a test case for the specific changes before reverting the patch.
> 
> However, I think there are still some timezone issues (as mentioned by Mark Frost on nagios-users), so I'm thinking that I should revert the entire patch and instead say that if you want to add the isdst=-1 in, then add test cases in.

The POSIX standard says [1]

<snip>
A positive or 0 value for tm_isdst shall cause mktime() to presume initially that Daylight Savings Time, respectively, is or is not in effect for the specified time. A negative value for tm_isdst shall cause mktime() to attempt to determine whether Daylight Savings Time is in effect for the specified time.
</snip>

Thus, unless you know for sure that daylight savings is in effect or not for a specific date, /not/ using tm_isdst < 0 is just plain wrong (iirc, the field was not initialised at all without my patch, which may give random results).

Note that tm_isdst < 0 has been marked as POSIX extension to ISO 9899, i.e. broken systems which do not implement POSIX (read: Winbloze) may fail here.  Probably the only resort is to use utc exclusively.

> Opinions?

What should be the purpose of a test case if the code strictly follows POSIX?

Best, Albrecht.

[1] <http://www.opengroup.org/onlinepubs/009695399/functions/mktime.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20100315/ef0fe3cf/attachment.sig>
-------------- next part --------------
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list