Title: HP Tru64 UNIX Operating Systems - TZ Environment Variable Uses Old DST Rules
Document ID: emr_na-c01411278-1
Submitted Date: Mon Mar 24 08:19:33 GMT 2008
Last Modified Date: Thu Apr 10 12:15:02 GMT 2008
HP Tru64 UNIX Operating Systems - TZ Environment Variable Uses Old DST Rules
ISSUE:
On a Tru64 UNIX system prior to V5.1B-4, which is updated with the Daylight Saving Time (DST) rules adopted by the U.S. and Canada in 2007, setting the TZ environment variable to a System-V style timezone such as EST5EDT causes the shell to use the old rules. As such, during the periods that observe DST only under the new rules, setting the TZ variable may incorrectly show the system as running standard time. This will occur from the second Sunday in March until the first Sunday in April, and again from the last Sunday in October until the first Sunday in November.
The issue is illustrated by the following example from a system in the U.S. Eastern timezone:
The zdump command verifies that the EST5EDT timezone is updated with the new DST rules (starting in March, ending in November):
# zdump -v :EST5EDT | grep 2008
:EST5EDT Wed Mar 19 08:31:30 2008 EDT [this will show the current time]
:EST5EDT Sun Mar 9 06:59:59 2008 GMT = Sun Mar 9 01:59:59 2008 EST isdst=0 gmtoff=-18000
:EST5EDT Sun Mar 9 07:00:00 2008 GMT = Sun Mar 9 03:00:00 2008 EDT isdst=1 gmtoff=-14400
:EST5EDT Sun Nov 2 05:59:59 2008 GMT = Sun Nov 2 01:59:59 2008 EDT isdst=1 gmtoff=-14400
:EST5EDT Sun Nov 2 06:00:00 2008 GMT = Sun Nov 2 01:00:00 2008 EST isdst=0 gmtoff=-18000
During one of the periods at issue, the date command incorrectly shows the system as being on standard time if TZ is set to a timezone such as EST5EDT . For example:
# ksh
# date Tue Mar 18 12:38:37 EDT 2008 <-- correctly shows system at EDT
# TZ=EST5EDT date Tue Mar 18 11:38:42 EST 2008 <-- incorrectly shows system at EST
# TZ=:EST5EDT date Tue Mar 18 12:38:49 EDT 2008 <-- with slightly different syntax (leading colon in timezone name), correctly shows system at EDT.
SOLUTION:
This issue is corrected in Tru64 UNIX V5.1B-4. For earlier systems, various workarounds are available.
The issue is caused by the way in which the shell interprets the TZ environment variable. Tru64 UNIX conforms to the POSIX standards listed in the reference page standards(5). In particular, ISEE Std 1003.1 , Section 8 describes the specifications for environment variables. The 2004 edition can be found online. Click here to view the "IEEE Std 1003.1, 2004 Edition" (
http://www.opengroup.org/onlinepubs/...bd_chap08.html) Non-HP site .
The TZ variable is listed in Section 8.3, Other Environment Variables . Two forms of specification are allowed:
:characters
or:
std offset dst offset, rule
In the first form, the interpretation is implementation dependent. The Tru64 UNIX implementation is described in the reference page for timezone(3). This states:
[Tru64 UNIX] If TZ has the colon-pathname format (
athname), the characters following the colon specify the pathname of a tzfile(4) format file from which to read the time conversion information. A pathname beginning with a slash (/) represents an absolute pathname; otherwise, the pathname is relative to the system time conversion information directory /etc/zoneinfo.
What this means is that if TZ is specified as something like :US/Eastern or :EST5EDT , the shell will read the DST rules from the timezone files /etc/zoneinfo/US/Eastern or /etc/zoneinfo/EST5EDT . These timezone files are built from the source files in /etc/zoneinfo/sources .
This why the leading-colon specification works.
Why does the format without the colon not work with the new DST rules? This has to do with the expansion of the second TZ format in the POSIX standard. The full form of this format for TZ is:
stdoffset[dst[offset][,start[/time],end[/time]]]
This means that the full specification should be something like the following:
TZ=EST5EDT4,M3.2.0,M11.1.0
This specifies TZ completely for the new rules, changing on the second Sunday in March and the first Sunday in November.
However, if the optional fields are omitted (as when TZ is specified as just EST5EDT ), the handling of those fields is not specified by the POSIX standard, and is therefore implementation dependent. In Tru64 UNIX, the default handling in this case is to use the U.S. DST rules that are in force at the time the software is released. For any version prior to V5.1B-4, this is equivalent to the following specification, which matched the old DST rules that were in force when those versions were released:
TZ=EST5EDT4,M4.1.0,M10.5.0
As such, versions earlier than V5.1B-4 pick up this definition as a default behavior of the shell, regardless of whether the timezone source files have been updated. For these earlier versions, there are a variety of workarounds:
Specify the TZ environment variable with a leading colon (TZ=:EST5EDT rather than TZ=EST5EDT ). This will cause the shell to read the EST5EDT definition from the timezone database, rather than interpreting it according to the POSIX standard.
Alternatively, specify the full form of the TZ variable as defined by the POSIX standard. For example:
export TZ=EST5EDT4,M3.2.0,M11.1.0
If it is not possible to use one of the previously mentioned alternative formats, a third alternative is to update the default rules used by the shell in Tru64 UNIX version 5. This is possible because version 5 defines the POSIX default rules in a file, /etc/zoneinfo/posixrules .
In version 4 and earlier, the rules are hard-coded in the C library, so this workaround does not apply to those versions. To update the rules, simply replace the system copy of /etc/zoneinfo/posixrules with a copy from a system running V5.1B-4 or later. The shell will immediately start using the new rules; no reboot is necessary.