Article View: comp.std.c
Article #4177Re: mktime murk
From: Larry Jones
Date: Wed, 04 Oct 1995 15:07
Date: Wed, 04 Oct 1995 15:07
34 lines
2023 bytes
2023 bytes
In article <44qa5g$qj8@tattoo.twinsun.com>, eggert@twinsun.com (Paul Eggert) writes: > For example, this program asks for 1996-01-01 00:00:00 daylight savings time: > [...] > Assuming US Pacific rules, which use standard time on New Year's Day, > should this program output > (1) `1995-12-31 23:00:00 isdst=0', or > (2) `1995-01-01 00:00:00 isdst=0'? > Which output is correct, and why? The former. The footnote (139 in ANSI Classic) makes the intent clear: Thus, a positive or zero value for tm_isdst causes the mktime function to presume initially that Daylight Saving Time, respectively, is or is not in effect for the specified time. This corresponds to your first interpretation: > One interpretation is that mktime should use a non-negative tm_isdst to > decide whether the time is standard or daylight, regardless of whether > what kind of time was actually used. This interpretation yields (1) > above. The Rationale further supports this interpretation by noting that a very common use of mktime is to take an existing time_t, convert it to a struct tm, add or subtract a number of minutes, hours, days, etc., and then use mktime to convert back to a time_t. Your second interpretation would produce incorrect results when such calculations crossed DST boundaries. You are correct that there are still ambiguities when the DST offset changes, but such changes are not very common. ---- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070 larry.jones@sdrc.com Is it too much to ask for an occasional token gesture of appreciation?! -- Calvin
Technical Details
Message-ID:
<44u7um$elm@info1.sdrc.com>Path:
arc1-ca.pugleaf.net!sdrc.com!thor!scjonesReferences:
<44mio5$63n@mark.ucdavis.edu> <812657476snz@genesis.demon.co.uk> <44qa5g$qj8@tattoo.twinsun.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sdrc.com!thor!scjones From: scjones@thor.sdrc.com (Larry Jones) Newsgroups: comp.std.c Subject: Re: mktime murk Date: 4 Oct 1995 15:07:02 GMT Organization: SDRC Engineering Services Distribution: world Message-ID: <44u7um$elm@info1.sdrc.com> References: <44mio5$63n@mark.ucdavis.edu> <812657476snz@genesis.demon.co.uk> <44qa5g$qj8@tattoo.twinsun.com> NNTP-Posting-Host: thor.sdrc.com