TZ environment variable

Paul Eggert eggert at CS.UCLA.EDU
Tue May 10 03:55:19 UTC 2005


matthew green <mrg at eterna.com.au> writes:

> i think it must be lowered to at least 2 - i use "TZ=GB" in a script
> somewhere...

But we're talking about the length of the time zone abbreviation
(e.g., "GMT" or "BST"), which is distinct from the length of the TZ
string itself.

Another check, which Garrett Wollman alluded to, is that the GMT
offset should be "sane".  For example, it's reasonable to reject
settings like TZ="XXX9999999999".

However, that leaves the issue of what is "sane".
For example, Solaris 8 supports a wide range of "sane" offsets:

$ date -u; TZ=XXX24:59:59 date; TZ=XXX444444 date
Tue May 10 03:51:24 GMT 2005
Mon May  9 02:51:25 XXX 2005
Fri Aug 27 15:51:24 XXX 1954

but this has been tightened up in Solaris 10:

$ date -u; TZ=XXX24:59:59 date; TZ=XXX444444 date
Tue May 10 03:50:45 GMT 2005
Mon May  9 02:50:46 XXX 2005
Tue May 10 03:50:45 GMT 2005

I suspect this is for reasons similar to what Garrett Wollman
mentioned.

POSIX requires support only for UTC offsets in the range -24:59:59
through +24:59:59.  (The implied daylight-saving UTC offset can be as
high as +25:59:59.)  The GNU C library supports only the POSIX range.
I don't know the range that Solaris 10 supports.



More information about the tz mailing list