On Tue, Oct 14, 2008 at 10:04 AM, Mark B. <[EMAIL PROTECTED]> wrote: ... > My best guess is that mktime() expects tm_isdst but strptime() doesn't > load it. But I don't know how to work around this.
strptime() doesn't have enough information to set the tm_isdst member. Indeed, if you set it yourself before calling strptime(), it'll leave it unaltered. Right now, you're setting it to zero via a memset(). Let's see what the mktime() manpage says about tm_isdst: (A positive or zero value for tm_isdst causes mktime() to presume initially that summer time (for example, Daylight Saving Time in the U.S.A.) respectively, is or is not in effect for the specified time. A negative value for tm_isdst causes the mktime() func- tion to attempt to divine whether summer time is in effect for the speci- fied time; in this case it does not use a consistent rule and may give a different answer when later presented with the same argument.) Sounds like you're expecting the behavior of tm_isdst < 0, so set it to negative one before calling mktime. (The "not a consistent rule" is because there's an hour of date-time strings every year that repeat, first with summer time, then with standard time. If you can't stand the ambiguity, then you need to carry the zone information along with your date-time strings and then do the zone handling yourself.) Philip Guenther