Timezones anyone?

Guy Harris auspex!guy at uunet.uu.net
Tue Apr 10 03:33:47 AEST 1990


>I have a function that will take a time structure and return the long
>integer representation of that time structure (the reverse of
>localtime()), but it requires the tm_isdst to be set.

So does SunOS 4.x (the "struct tm" you gave included "tm_zone" and
"tm_isgmtoff", so you have 4.x), and theirs *doesn't* require "tm_isdst"
to be set - it leaves "tm_isdst" set to the correct value.  See the
description of "timelocal()" in CTIME(3).  (This routine comes with the
Arthur Olson time zone code distribution - that's whence the SunOS version
came - so other systems may have it as well.)

SunOS 4.1 will have the ANSI C "mktime()" routine, which is similar except
that you'd have to set "tm_isdst" to -1 to have it figure out whether the
time was in DST or not.  (That routine comes with the most recent version
of the Olson time zone code distribution, and since it's in the ANSI C
spec most systems will eventually have it.)



More information about the Comp.sys.sun mailing list