Q: how to handle switch to daylight savings time in System V.2?

Guy Harris guy at auspex.auspex.com
Sat Apr 15 17:50:23 AEST 1989


>What is the proper way to handle daylight savings time under System V?
>When the Big Day came and the date command didn't automatically handle the
>adjustment and I couldn't find any documentation on how to handle the change

Since you have S5R2, you may not *have* a way to handle the change - the
rules are probably linked into every program on your system, alas.

>I elected to just reboot the computer and adjust the hardware clock.  That got
>the "date" command to work okay but created a problem with compiled programs
>which use code such as:
>  time(&Seconds);   /*fetch time from system*/
>  TimeRec=localtime(&Seconds);          /*convert it to structure*/
>  return(TimeRec->tm_yday);             /*1..365*/
>to determine the day of the year.  They now think that 11 pm is the start of
>the new day!

Uhh, yup.  Adjusting the hardware clock is Not A Good Idea.  UNIX keeps
its time in UTC (or some approximation thereof) internally, and the
software really expects the hardware clock to be set by GMT.

>The .profile and .cshrc files set the environment variable "TZ" to "PST8PDT".
>The PST must stand for 'Pacific Standard Time' and the 8 is apparently the
>hour offset from GMT.  But what is the PDT for?  'Pacific Daylight
>Time'?

You got it.

>Where is this documented, anyway?

CTIME(3C), probably.  It *is* documented in S5R3's documentation; I
think it was documented in previous releases.

Basically, the S5R2 flavor of TZ is of the form

	<zonename><offset>[<zonename>]

The first <zonename> is a 3-character abbreviation for the time zone
name; this is the name that'll show up in the output from "date", for
example.  <offset> is the offset from UTC, in hours - half-hours aren't
supported in vanilla S5R2.  Positive offsets are west of Greenwich,
negative offsets are east of Greenwich.  The second <zonename>, if
present, indicates that your machine should honor Daylight Savings Time,
with the pre-1986 US rules; that <zonename> is a 3-character
abbreviation for the time zone name to be used when Daylight Savings
Time is in effect.

Basically, with vanilla S5R2, you're stuck with the trick another poster
suggested, namely setting TZ in a funny fashion temporarily.

Some UNIX systems have been updated to know about the new US DST rules;
others have schemes that can cope with the change to the US DST rules,
and with DST rules other than the US rules.



More information about the Comp.unix.questions mailing list