timd> I'm trying to get some help with 'time' C Run-Time Library functions
timd> under HP-UX. Here's the nature of the problem:
timd> Say you have a system where the kernel parameters for timezone
timd> are set to Mountain Standard Time, and you set the system date
timd> using the 'date' command for January 1, 1970 (the start of UNIX
timd> The time () function will always return a value offset by the
timd> timezone set in the kernel.
Nope. time() always returns GMT - the kernel timezone is not used.
timd> Now say that you want to construct a time from scratch in a client
timd> process in a different timezone.
timd> export TZ=AST4ADT (Atlantic Daylight Savings Time)
timd> If you try to construct a time for January 1, 1970 using the
timd> 'mktime' function you will not achieve the correct results.
timd> struct tm timeStruct;
timd> time_t timeValue;
timd> memset (&timeStruct, 0, sizeof (struct tm));
timd> timeStruct.tm_year = 70;
timd> timeStruct.tm_mon = 0; (month - 1)
timd> timeStruct.tm_mday = 1;
timd> timeValue = mktime (&timeStruct);
timd> timeValue = 14400;
timd> Notice that the time value returned only takes into account the
timd> local time zone set in the TZ environment variable.
timd> I'm trying to find a way in HP-UX to determine what the system clock
timd> time zone offset (e.g. 25,200) is.
You don't need it.
timd> I've noticed that there is a 'gettimeofday' non-ANSI call under
timd> HP-UX that returns me the minutes west of Greenwich. This gets me
timd> close, but still does not tell me whether Daylight Savings Time
timd> is in effect for the kernel time zone, only whether Daylight Savings
timd> Time gets used for the time zone.
Forget about the kernel timezone - it's never visible at user level
(gettimeofday can read it, but there's never any reason to). It is a
historical fossil only.
As far as time(), and *every* system call that takes or returns timestamps
is concerned, there is no timezone, only seconds since 1-1-70 0:00 GMT.
Timezones are only used to convert between seconds-since-Epoch and forms
more meaningful to the user.