No. "mktime()" - which is also in SunOS 4.1[.x] (although not inQuote:>Do these functions pay any attention at all to the:
> int tm_isdst; /* 1 if DST in effect */
> char *tm_zone; /* abbreviation of timezone name */
> long tm_gmtoff; /* offset from GMT in seconds */
>fields of the struct tm handed to them?
4.0[.x]), and is the official ANSI C standard interface for this - does
pay attention to "tm_isdst", for reasons that are, I think, somewhat
bogus. However, "timelocal()" and "timegm()" do not.
None of the three routines pay any attention whatsoever to "tm_zone" or
"tm_gmtoff".
The programmer is expected to use "timelocal()" only to convert localQuote:>Is the programmer expected to
>track whether the value in the struct tm represents some local time
>(correlated to current [non]-setting of TZ) or do these functions
>attempt to use the values in the above fields?
times, in the time zone specified by the current [non-]setting of TZ, to
UNIX times, and is expected to use "timegm()" only to convert time
specifications for UTC into UNIX times.
The programmer is *also* not expected to stuff anything into "tm_zone"
nor "tm_gmtoff", and is not expected to stuff anything into "tm_isdst"
before a call to "timelocal()" or "timegm()"; the programmer should
stuff -1 into "tm_isdst" before calling "mktime()" - -1 says "I don't
know if it's DST or not, *you* tell *me* whether it is".
(The programmer is *NOT* expected to know whether the time in question
is during Daylight Savings Time or not; take a look at some of the
source files in "/usr/share/lib/zoneinfo", and ask yourself whether you
*WANT* your software to have to worry about the quirks of N legislatures
throughout the world - that's the whole reason Arthur Olson and the rest
of the Timezone Caballeros came up with that software in the first
place....)
If the programmer wishes to convert times for some arbitrary time zone,
they are expected to set the environment variable TZ to the appropriate
value for that time zone, call "tzset()", and then convert the time.
March through the environment by hand and rip any TZ setting out of it.Quote:>How do I do the equivalent of an unsetenv TZ programmatically?
No, because you can either rip TZ out of the environment by hand, or do:Quote:>Am I stuck _requiring_ that TZ be set to something upon program
>startup?
putenv("TZ=localtime");
which has the same effect. ("localtime" here means the string beginning
with the letter 'l', followed by the letter 'o', followed by... i.e.,
it's not a place-holder for the current time zone, it's the string
"localtime".)