>From 61bdaa139a38d5accdcca852bc58880966611335 Mon Sep 17 00:00:00 2001 From: Paul Eggert 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 + + 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 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