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

To reply to this bug, email your comments to 14229 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#14229; Package coreutils. (Thu, 18 Apr 2013 20:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Donald Berry <dberry <at> redhat.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 18 Apr 2013 20:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Donald Berry <dberry <at> redhat.com>
To: bug-coreutils <at> gnu.org
Subject: invalid TZ and /bin/date
Date: Thu, 18 Apr 2013 16:24:08 -0400 (EDT)
If an invalid TZ argument is passed to /bin/date, it silently fails but prints the UTC result:
[dberry <at> dberry ~]$ TZ=EDT date -d @0
Thu Jan  1 00:00:00 EDT 1970
[dberry <at> dberry ~]$ TZ=foo date -d @0
Thu Jan  1 00:00:00 foo 1970

It works correctly if using no argument or a valid argument:
[dberry <at> dberry ~]$ date -d @0
Wed Dec 31 19:00:00 EST 1969
[dberry <at> dberry ~]$ TZ=EST5EDT date -d @0
Wed Dec 31 19:00:00 EST 1969
[dberry <at> dberry ~]$ TZ=UTC date -d @0
Thu Jan  1 00:00:00 UTC 1970

[dberry <at> dberry ~]$ rpm -q coreutils
coreutils-8.4-19.el6.x86_64
[dberry <at> dberry ~]$ uname -a
Linux dberry.csb 2.6.32-279.19.1.el6.x86_64 #1 SMP Sat Nov 24 14:35:28 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
[dberry <at> dberry ~]$ cat /etc/redhat-release 
Red Hat Enterprise Linux Workstation release 6.3 (Santiago)
[dberry <at> dberry ~]$ date
Thu Apr 18 16:23:46 EDT 2013

Donald Berry, RHCE
Technical Account Manager
Red Hat Canada Ltd.
mobile: 647-338-6329





Information forwarded to bug-coreutils <at> gnu.org:
bug#14229; Package coreutils. (Thu, 18 Apr 2013 21:35:01 GMT) Full text and rfc822 format available.

Message #8 received at 14229 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Donald Berry <dberry <at> redhat.com>
Cc: 14229 <at> debbugs.gnu.org
Subject: Re: bug#14229: invalid TZ and /bin/date
Date: Thu, 18 Apr 2013 14:29:33 -0700
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.





Information forwarded to bug-coreutils <at> gnu.org:
bug#14229; Package coreutils. (Fri, 19 Apr 2013 19:53:02 GMT) Full text and rfc822 format available.

Message #11 received at 14229 <at> debbugs.gnu.org (full text, mbox):

From: Donald Berry <dberry <at> redhat.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 14229 <at> debbugs.gnu.org
Subject: Re: 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.





Information forwarded to bug-coreutils <at> gnu.org:
bug#14229; Package coreutils. (Fri, 19 Apr 2013 20:29:01 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mike Frysinger <vapier <at> gentoo.org>
To: bug-coreutils <at> gnu.org
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, Donald Berry <dberry <at> redhat.com>,
	14229 <at> debbugs.gnu.org
Subject: Re: bug#14229: invalid TZ and /bin/date
Date: Fri, 19 Apr 2013 16:26:18 -0400
[Message part 1 (text/plain, inline)]
On Friday 19 April 2013 15:47:46 Donald Berry wrote:
> Yes, date/GNU accepts whatever TZ string you pass it without error, but
> this leads to very confusing results.
Paul said the "GNU system", not "GNU/date".  coreutils doesn't parse the TZ 
env var, the C library does.  similarly, the date program doesn't do the time 
parsing, it relies on the C library to handle these details.  your use of 
`date` here is just the simplest way from the command line to test the C 
library.  you can write C code that calls the timezone funcs and see the same 
behavior.

> Is there any documentation of what the supported/recognized TZ strings are?
>  Are there any plans to reject invalid strings?

in the GNU system, that means glibc does the parsing.  so review the glibc 
manual for details:
http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
-mike
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#14229; Package coreutils. (Fri, 19 Apr 2013 20:29:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#14229; Package coreutils. (Fri, 19 Apr 2013 21:12:02 GMT) Full text and rfc822 format available.

Message #20 received at 14229 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Donald Berry <dberry <at> redhat.com>
Cc: 14229 <at> debbugs.gnu.org
Subject: Re: bug#14229: invalid TZ and /bin/date
Date: Thu, 18 Apr 2013 15:45:20 -0700
On 04/18/2013 01:24 PM, Donald Berry wrote:
> If an invalid TZ argument is passed to /bin/date, it silently fails but prints the UTC result:
> [dberry <at> dberry ~]$ TZ=EDT date -d @0
> Thu Jan  1 00:00:00 EDT 1970
> [dberry <at> dberry ~]$ TZ=foo date -d @0
> Thu Jan  1 00:00:00 foo 1970
> 
> It works correctly if using no argument or a valid argument:
> [dberry <at> dberry ~]$ date -d @0
> Wed Dec 31 19:00:00 EST 1969
> [dberry <at> dberry ~]$ TZ=EST5EDT date -d @0
> Wed Dec 31 19:00:00 EST 1969
> [dberry <at> dberry ~]$ TZ=UTC date -d @0
> Thu Jan  1 00:00:00 UTC 1970
> 
> [dberry <at> dberry ~]$ rpm -q coreutils
> coreutils-8.4-19.el6.x86_64
> [dberry <at> dberry ~]$ uname -a
> Linux dberry.csb 2.6.32-279.19.1.el6.x86_64 #1 SMP Sat Nov 24 14:35:28 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
> [dberry <at> dberry ~]$ cat /etc/redhat-release 
> Red Hat Enterprise Linux Workstation release 6.3 (Santiago)
> [dberry <at> dberry ~]$ date
> Thu Apr 18 16:23:46 EDT 2013

This is really annoying and confusing.
However as I understand it, there is no interface currently
that coreutils can use, to determine that a match wasn't found.
All I can recommend is to use location based zone instead
which have less scope for mismatches:
http://www.pixelbeat.org/docs/linux_timezones/

thanks,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#14229; Package coreutils. (Fri, 19 Apr 2013 21:20:01 GMT) Full text and rfc822 format available.

Message #23 received at 14229 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Donald Berry <dberry <at> redhat.com>
Cc: 14229 <at> debbugs.gnu.org
Subject: Re: bug#14229: invalid TZ and /bin/date
Date: Fri, 19 Apr 2013 14:14:42 -0700
On 04/19/2013 12:47 PM, Donald Berry wrote:
> Are there any plans to reject invalid strings?

Not as far as I know.




Severity set to 'wishlist' from 'normal' Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Mon, 15 Oct 2018 23:39:02 GMT) Full text and rfc822 format available.

Merged 9614 11748 14229. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Mon, 15 Oct 2018 23:39:03 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 201 days ago.

Previous Next


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