[comp.unix.microport] Q: how to handle switch to daylight savings time in System V.2?

stever@tree.UUCP (Steve Rudek) (04/13/89)

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
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!

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'?
Where is this documented, anyway?  Obviously it is unreasonable to expect AT&T
to properly index their documentation until UNIX is more than 20 years old and
produces more than a billion in annual revenue.

tim@crackle.amd.com (Tim Olson) (04/13/89)

In article <265@tree.UUCP> stever@tree.UUCP (Steve Rudek) writes:
| 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
| 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:

It also messes up makes, etc.

| 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'?
| Where is this documented, anyway?  Obviously it is unreasonable to expect AT&T
| to properly index their documentation until UNIX is more than 20 years old and
| produces more than a billion in annual revenue.

One "simple" fix is to change the global .profile TZ to "PST7" for a
week or so, then when the old daylight savings time rule has kicked in,
change the variable back to PST8PDT.


	-- Tim Olson
	Advanced Micro Devices
	(tim@amd.com)

guy@auspex.auspex.com (Guy Harris) (04/15/89)

>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.