GNU bug report logs - #63349
Bug in date when using UTC/GMT timeszones in the TZ variable

Previous Next

Package: coreutils;

Reported by: Eiríkur Hjartarson <eiki <at> inan.is>

Date: Sun, 7 May 2023 13:49:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63349 in the body.
You can then email your comments to 63349 AT debbugs.gnu.org in the normal way.

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#63349; Package coreutils. (Sun, 07 May 2023 13:49:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eiríkur Hjartarson <eiki <at> inan.is>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 07 May 2023 13:49:02 GMT) Full text and rfc822 format available.

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

From: Eiríkur Hjartarson <eiki <at> inan.is>
To: bug-coreutils <at> gnu.org
Subject: Bug in date when using UTC/GMT timeszones in the TZ variable
Date: Sun, 7 May 2023 13:28:28 +0000
Hi,

I'm on Fedora-38 GNU/Linux and the version string of 'date' is "date 
(GNU coreutils) 9.1".

$ ls -l /etc/localtime
lrwxrwxrwx. 1 root root 40 jan 11  2022 /etc/localtime -> 
../usr/share/zoneinfo/Atlantic/Reykjavik

Now the "bug":

$ TZ=Europe/Riga date --iso-8601=minutes -d "2024-01-01T00:00-05:00"
2024-01-01T07:00+02:00

$ TZ=UTC+2 date --iso-8601=minutes -d "2024-01-01T00:00-05:00"
2023-01-01T03:00-02:00

That is: the first command gives me the time and date in Riga when it's
midnight at new year's eve in New York.

The second command should do the same but instead gives the time in 
Godthab Greenland.

$ TZ=America/Godthab date -d "2024-01-01T00:00-05:00" --iso-8601=minutes
2024-01-01T03:00-02:00

It seems to me that the sign in the timezone variable could be simply 
reversed.

Regards,
-- 
Eiríkur




Information forwarded to bug-coreutils <at> gnu.org:
bug#63349; Package coreutils. (Sun, 07 May 2023 14:53:01 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Eiríkur Hjartarson via GNU coreutils Bug Reports
 <bug-coreutils <at> gnu.org>
Cc: 63349 <at> debbugs.gnu.org, Eiríkur Hjartarson <eiki <at> inan.is>
Subject: Re: bug#63349: Bug in date when using UTC/GMT timeszones in the TZ
 variable
Date: Sun, 07 May 2023 16:52:17 +0200
On Mai 07 2023, Eiríkur Hjartarson via GNU coreutils Bug Reports wrote:

> Now the "bug":

It's not a bug.

> $ TZ=Europe/Riga date --iso-8601=minutes -d "2024-01-01T00:00-05:00"
> 2024-01-01T07:00+02:00
>
> $ TZ=UTC+2 date --iso-8601=minutes -d "2024-01-01T00:00-05:00"
> 2023-01-01T03:00-02:00
>
> That is: the first command gives me the time and date in Riga when it's
> midnight at new year's eve in New York.
>
> The second command should do the same but instead gives the time in
> Godthab Greenland.

That's not how TZ works.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
says about the offset:

    Indicates the value added to the local time to arrive at Coordinated
    Universal Time. ...  If preceded by a '-', the timezone shall be
    east of the Prime Meridian; otherwise, it shall be west (which may
    be indicated by an optional preceding '+' ).

Thus TZ=UTC+2 means two hours before UTC.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-coreutils <at> gnu.org:
bug#63349; Package coreutils. (Sun, 07 May 2023 14:53:02 GMT) Full text and rfc822 format available.

Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sun, 07 May 2023 16:37:02 GMT) Full text and rfc822 format available.

Notification sent to Eiríkur Hjartarson <eiki <at> inan.is>:
bug acknowledged by developer. (Sun, 07 May 2023 16:37:02 GMT) Full text and rfc822 format available.

Message #16 received at 63349-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Andreas Schwab <schwab <at> linux-m68k.org>, 63349-done <at> debbugs.gnu.org
Cc: bug-gnulib <at> gnu.org, eiki <at> inan.is
Subject: Re: bug#63349: Bug in date when using UTC/GMT timeszones in the TZ
 variable
Date: Sun, 7 May 2023 12:36:48 -0400
[Message part 1 (text/plain, inline)]
On 5/7/23 07:52, Andreas Schwab wrote:
> Thus TZ=UTC+2 means two hours before UTC.


Yes, and this mistake seems to be common enough that I installed the 
attached patch into Gnulib, so that it'll propagate into the Coreutils 
manual, which should help people who read the 'date' documentation 
(admittedly only a subset of 'date' users).
[0001-Warn-against-bogus-TZ-settings.patch (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#63349; Package coreutils. (Sun, 07 May 2023 16:59:02 GMT) Full text and rfc822 format available.

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

From: Eiríkur Hjartarson <eiki <at> inan.is>
To: Andreas Schwab <schwab <at> linux-m68k.org>,
 Eiríkur Hjartarson via GNU coreutils Bug Reports
 <bug-coreutils <at> gnu.org>
Cc: 63349 <at> debbugs.gnu.org
Subject: Re: bug#63349: Bug in date when using UTC/GMT timeszones in the TZ
 variable
Date: Sun, 7 May 2023 16:58:34 +0000
On 7.5.2023 14:52, Andreas Schwab wrote:
> On Mai 07 2023, Eiríkur Hjartarson via GNU coreutils Bug Reports wrote:
> 
>> Now the "bug":
> 
> It's not a bug.

Thanks for the explanation, in my defense, I did read the date info page 
and the FAQ at https://www.gnu.org/software/coreutils/faq/coreutils-faq.html
.

Obviously I missed the reference to opengroup.

Regards,
-- 
Eiríkur




Information forwarded to bug-coreutils <at> gnu.org:
bug#63349; Package coreutils. (Sun, 07 May 2023 16:59:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 05 Jun 2023 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 326 days ago.

Previous Next


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