On Tue, Oct 14, 2008 at 11:19 AM, Mark B. <[EMAIL PROTECTED]> wrote: > On Tue, Oct 14, 2008 at 1:31 PM, Philip Guenther <[EMAIL PROTECTED]> wrote: ... >> strptime() doesn't have enough information to set the tm_isdst member. > > If it had a format specifier for timezone, then I guess it could > figure it out. But I don't see that format specifier in the > strptime() manual.
Right. That's probably because struct tm doesn't represent a time+offset, or even a location-independent time, but rather just "a broken down time". The meaning of a given struct tm value depends on the timezone you apply to it, which is why we have both localtime() and gmtime(), so create tm values that presume different timezone values. When dealing with this in the past (for parsing Date: header fields from email message, etc), I've generally parsed everything except the zone to get a struct tm, use timegm() to convert that to a UTC value, then corrected the returned time_t manually based on the zone information that was present to get the time_t for the absolute time represented. If only the "new date-time library" proposals that have been talked about on comp.std.c for *years* would ever achieve consensus... Philip Guenther