GNU bug report logs - #14229
invalid TZ and /bin/date

Previous Next

Package: coreutils;

Reported by: Donald Berry <dberry <at> redhat.com>

Date: Thu, 18 Apr 2013 20:30:02 UTC

Severity: wishlist

Merged with 9614, 11748

Full log


View this message in rfc822 format

From: Donald Berry <dberry <at> redhat.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 14229 <at> debbugs.gnu.org
Subject: bug#14229: invalid TZ and /bin/date
Date: Fri, 19 Apr 2013 15:47:46 -0400 (EDT)
Yes, date/GNU accepts whatever TZ string you pass it without error, but this leads to very confusing results.  Here again is one of the examples:

[dberry <at> dberry ~]$ TZ=foo date -d @0
Thu Jan  1 00:00:00 foo 1970

I think it is safe to say that 'foo' is not a valid timezone, and yet date returns the UTC result, but displays it as timezone foo.

Even more confusing is using a string that the user may think is valid, such as EDT.  Again date returns the UTC result, but displays it as timezone EDT.

[dberry <at> dberry ~]$ TZ=EDT date -d @0
Thu Jan  1 00:00:00 EDT 1970

It seems that when date does not understand the string it returns the UTC result, but echoes the string back as the apparent timezone, or at least attempts to - date has a limit on the number of characters it supports:

[dberry <at> dberry ~]$ TZ=America/Eastern date -d @0 # invalid TZ string
Thu Jan  1 00:00:00 America 1970

There are other strings that date does understand, and in fact translates them into another timezone in the output, e.g.:

[dberry <at> dberry ~]$ TZ=America/Phoenix date -d @0
Wed Dec 31 17:00:00 MST 1969

Is there any documentation of what the supported/recognized TZ strings are?  Are there any plans to reject invalid strings?  I did see there was a similar bug reported in 2011 (http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9614).  

Don

----- Original Message -----
From: "Paul Eggert" <eggert <at> cs.ucla.edu>
To: "Donald Berry" <dberry <at> redhat.com>
Cc: 14229 <at> debbugs.gnu.org
Sent: Thursday, April 18, 2013 5:29:33 PM
Subject: Re: bug#14229: invalid TZ and /bin/date

On 04/18/13 13:24, Donald Berry wrote:
> If an invalid TZ argument is passed to /bin/date,
> it silently fails but prints the UTC result

In the GNU system there is no such thing
as an invalid TZ string.  Every TZ string has
some interpretation (typically as UTC).
This is true not just for /bin/date, but for
every other program.





This bug report was last modified 6 years and 245 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.