bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Neil Hoggarth <neil.hoggarth@gmail.com>
Cc: Assaf Gordon <assafgordon@gmail.com>, bug-gnulib@gnu.org
Subject: Re: parse-datetime.y - Military Timezones are inverted from the correct sense
Date: Fri, 9 Aug 2019 14:01:35 -0700	[thread overview]
Message-ID: <bcc63a55-4258-2f00-c1e9-95b88f8188af@cs.ucla.edu> (raw)
In-Reply-To: <CAHr01vNxpg4xk5KFFPOd4uPEQABxfCo3nYQQd-Sx+8vkNSLxEg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

Thanks for mentioning this problem. The military timezone indicators 
(other than "Z") were purposely done backwards in 1999, to be compatible 
with Internet RFC 822 which also had them backwards and which was the 
standard for email at the time. RFC 5322, which is RFC 822's current 
version, says that because of the error these timezone indicators should 
all be treated as equivalent to "Z" now. So coreutils should be changed, 
either to follow the RFC 5322 recommendation, or to be compatible with 
traditional military use. The latter would make more sense since it is 
somewhat useful behavior and the RFC 5322 requirement is merely a 
SHOULD, not a MUST.

Since the RFC 822 error was fixed in 2001 when RFC 2822 came out, it is 
long past time to fix parse-datetime.y accordingly, so I installed the 
attached patch into Gnulib.

[-- Attachment #2: 0001-parse-datetime-fix-military-timezone-letters.patch --]
[-- Type: text/x-patch, Size: 3929 bytes --]

From 61bdaa139a38d5accdcca852bc58880966611335 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 9 Aug 2019 13:47:41 -0700
Subject: [PATCH] parse-datetime: fix military timezone letters

Problem and trivial fix reported by Neil Hoggarth in:
https://lists.gnu.org/r/bug-gnulib/2019-08/msg00005.html
* lib/parse-datetime.y (military_table):
Do it the right way, not the RFC 822 way.
---
 ChangeLog               |  8 +++++++
 doc/parse-datetime.texi |  4 +++-
 lib/parse-datetime.y    | 49 ++++++++++++++++++++++-------------------
 3 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 35f870abe..7616b5efd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-08-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+	parse-datetime: fix military timezone letters
+	Problem and trivial fix reported by Neil Hoggarth in:
+	https://lists.gnu.org/r/bug-gnulib/2019-08/msg00005.html
+	* lib/parse-datetime.y (military_table):
+	Do it the right way, not the RFC 822 way.
+
 2019-08-08  Eric Blake  <eblake@redhat.com>
 
 	configmake: Avoid namespace pollution issue on mingw.
diff --git a/doc/parse-datetime.texi b/doc/parse-datetime.texi
index 193575edc..2f1147572 100644
--- a/doc/parse-datetime.texi
+++ b/doc/parse-datetime.texi
@@ -306,7 +306,9 @@ only for @samp{UTC}; for example, @samp{UTC+05:30} is equivalent to
 Time zone items other than @samp{UTC} and @samp{Z}
 are obsolescent and are not recommended, because they
 are ambiguous; for example, @samp{EST} has a different meaning in
-Australia than in the United States.  Instead, it's better to use
+Australia than in the United States, and @samp{A} has different
+meaning as a military time zone than as an obsolescent
+RFC 822 time zone.  Instead, it's better to use
 unambiguous numeric time zone corrections like @samp{-0500}, as
 described in the previous section.
 
diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y
index 780575919..d371b9cb1 100644
--- a/lib/parse-datetime.y
+++ b/lib/parse-datetime.y
@@ -1160,34 +1160,37 @@ static table const time_zone_table[] =
 
 /* Military time zone table.
 
+   RFC 822 got these backwards, but RFC 5322 makes the incorrect
+   treatment optional, so do them the right way here.
+
    Note 'T' is a special case, as it is used as the separator in ISO
    8601 date and time of day representation.  */
 static table const military_table[] =
 {
-  { "A", tZONE, -HOUR ( 1) },
-  { "B", tZONE, -HOUR ( 2) },
-  { "C", tZONE, -HOUR ( 3) },
-  { "D", tZONE, -HOUR ( 4) },
-  { "E", tZONE, -HOUR ( 5) },
-  { "F", tZONE, -HOUR ( 6) },
-  { "G", tZONE, -HOUR ( 7) },
-  { "H", tZONE, -HOUR ( 8) },
-  { "I", tZONE, -HOUR ( 9) },
-  { "K", tZONE, -HOUR (10) },
-  { "L", tZONE, -HOUR (11) },
-  { "M", tZONE, -HOUR (12) },
-  { "N", tZONE,  HOUR ( 1) },
-  { "O", tZONE,  HOUR ( 2) },
-  { "P", tZONE,  HOUR ( 3) },
-  { "Q", tZONE,  HOUR ( 4) },
-  { "R", tZONE,  HOUR ( 5) },
-  { "S", tZONE,  HOUR ( 6) },
+  { "A", tZONE,  HOUR ( 1) },
+  { "B", tZONE,  HOUR ( 2) },
+  { "C", tZONE,  HOUR ( 3) },
+  { "D", tZONE,  HOUR ( 4) },
+  { "E", tZONE,  HOUR ( 5) },
+  { "F", tZONE,  HOUR ( 6) },
+  { "G", tZONE,  HOUR ( 7) },
+  { "H", tZONE,  HOUR ( 8) },
+  { "I", tZONE,  HOUR ( 9) },
+  { "K", tZONE,  HOUR (10) },
+  { "L", tZONE,  HOUR (11) },
+  { "M", tZONE,  HOUR (12) },
+  { "N", tZONE, -HOUR ( 1) },
+  { "O", tZONE, -HOUR ( 2) },
+  { "P", tZONE, -HOUR ( 3) },
+  { "Q", tZONE, -HOUR ( 4) },
+  { "R", tZONE, -HOUR ( 5) },
+  { "S", tZONE, -HOUR ( 6) },
   { "T", 'T',    0 },
-  { "U", tZONE,  HOUR ( 8) },
-  { "V", tZONE,  HOUR ( 9) },
-  { "W", tZONE,  HOUR (10) },
-  { "X", tZONE,  HOUR (11) },
-  { "Y", tZONE,  HOUR (12) },
+  { "U", tZONE, -HOUR ( 8) },
+  { "V", tZONE, -HOUR ( 9) },
+  { "W", tZONE, -HOUR (10) },
+  { "X", tZONE, -HOUR (11) },
+  { "Y", tZONE, -HOUR (12) },
   { "Z", tZONE,  HOUR ( 0) },
   { NULL, 0, 0 }
 };
-- 
2.21.0


  parent reply	other threads:[~2019-08-09 21:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 11:31 parse-datetime.y - Military Timezones are inverted from the correct sense Neil Hoggarth
2019-08-09 14:43 ` Assaf Gordon
2019-08-09 21:01 ` Paul Eggert [this message]
2019-08-10  2:26   ` Assaf Gordon
2019-08-10  7:46     ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bcc63a55-4258-2f00-c1e9-95b88f8188af@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=assafgordon@gmail.com \
    --cc=bug-gnulib@gnu.org \
    --cc=neil.hoggarth@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).