bug#63349: Bug in date when using UTC/GMT timeszones in the TZ variable
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
bug#63349: Bug in date when using UTC/GMT timeszones in the TZ variable
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). From 9f205ff9624b8e10b4331432c59bc732b8c1a7fe Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 7 May 2023 09:28:57 -0700 Subject: [PATCH] Warn against bogus TZ settings * doc/parse-datetime.texi (Specifying time zone rules): Warn against TZ="UTC=5". --- ChangeLog | 6 ++ doc/parse-datetime.texi | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 06ff163e0e..823d32b66f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-05-07 Paul Eggert + + Warn against bogus TZ settings + * doc/parse-datetime.texi (Specifying time zone rules): + Warn against TZ="UTC=5". + 2023-05-05 Bruno Haible dirfd: Add tests. diff --git a/doc/parse-datetime.texi b/doc/parse-datetime.texi index d54d7660c8..ec0160da8e 100644 --- a/doc/parse-datetime.texi +++ b/doc/parse-datetime.texi @@ -574,6 +574,9 @@ This example uses the somewhat-confusing POSIX convention for rules. and the time zone is 7 hours west of Greenwich, and @samp{TZ="<+0530>-5:30"} says that the time zone abbreviation is @samp{+0530} and the time zone is 5 hours 30 minutes east of Greenwich. +(One should never use a setting like @samp{TZ="UTC-5"}, since +this would incorrectly imply that local time is five hours east of +Greenwich and the time zone is called ``UTC''.) Although trickier POSIX @env{TZ} settings like @samp{TZ="<-05>+5<-04>,M3.2.0/2,M11.1.0/2"} can specify some daylight saving regimes, location-based settings like -- 2.40.1
bug#63349: Bug in date when using UTC/GMT timeszones in the TZ variable
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, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
bug#63349: Bug in date when using UTC/GMT timeszones in the TZ variable
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