Subject: Re: bug#18328: can't say date -d '8pm -0500' though other combos work

From: Assaf Gordon <[email-masked]>
Date: Fri, 19 Oct 2018 22:25:00 -0600

tags 18328 confirmed
retitle 18328 date: '8pm -0500' is invalid (am/pm problem)
stop

(triaging old bugs)

Hello,

On 25/08/14 10:01 AM, 積丹尼 Dan Jacobson wrote:
> $ date -d '8pm -0500'
> date: invalid date ‘8pm -0500’ <--why can't this combo work?

This is indeed a bug (specifically in gnulib's date parsing module,
but easier to track here).

It seems the existence of the "am/pm" string causes the parser
to take a slightly different rule, then reject additional relative
values, unless they have a unit, e.g.:

   $ date --debug -d '8pm +5 days'
   date: parsed time part: 08:00:00pm
   date: parsed relative part: +5 day(s)
   [...]

Contrast it with a different (and confusing) rules when there is
no "am/pm", the relative number is always taken as the time zone, e.g.:

   $ date --debug -d '8:00 +5 days'
   date: parsed time part: 08:00:00 UTC+05
   date: parsed relative part: +1 day(s)
   date: input timezone: parsed date/time string (+05)
   [...]

(from https://bugs.gnu.org/17161#31 )

I hope to get to this bug soon.

-assaf