GNU bug report logs - #35632
date Parse of '13:00 + 2 hours' Broken.

Previous Next

Package: coreutils;

Reported by: Ralph Corderoy <ralph <at> inputplus.co.uk>

Date: Wed, 8 May 2019 11:58:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

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 35632 in the body.
You can then email your comments to 35632 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#35632; Package coreutils. (Wed, 08 May 2019 11:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ralph Corderoy <ralph <at> inputplus.co.uk>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 08 May 2019 11:58:01 GMT) Full text and rfc822 format available.

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

From: Ralph Corderoy <ralph <at> inputplus.co.uk>
To: bug-coreutils <at> gnu.org
Subject: date Parse of '13:00 + 2 hours' Broken.
Date: Wed, 08 May 2019 12:57:10 +0100
Hi,

Using date from coreutils 8.31-1 on Arch Linux.
This surprised me.

    $ TZ=UTC0 /bin/date -d '1pm + 2 hours'
    Wed  8 May 15:00:00 UTC 2019
    $ TZ=UTC0 /bin/date -d '13:00 + 2 hours'
    Wed  8 May 12:00:00 UTC 2019

The documentation doesn't suggest `1pm' and `13:00' are treated
differently.  `--debug' helps.

    $ TZ=UTC0 /bin/date --debug -d '1pm + 2 hours'
    date: parsed time part: 01:00:00pm
    date: parsed relative part: +2 hour(s)
    ...
    $ TZ=UTC0 /bin/date --debug -d '13:00 + 2 hours'
    date: parsed time part: 13:00:00 UTC+02
    date: parsed relative part: +1 hour(s)
    date: input timezone: parsed date/time string (+02)
    ...

It looks like parsing is broken in the second case.

The result I wanted can also be obtained my omitting the `+'.

    $ TZ=UTC0 /bin/date -d '1pm 2 hours'
    Wed  8 May 15:00:00 UTC 2019
    $ TZ=UTC0 /bin/date -d '13:00 2 hours'
    Wed  8 May 15:00:00 UTC 2019

-- 
Cheers, Ralph.




Information forwarded to bug-coreutils <at> gnu.org:
bug#35632; Package coreutils. (Wed, 26 Jun 2019 14:54:02 GMT) Full text and rfc822 format available.

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

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Ralph Corderoy <ralph <at> inputplus.co.uk>
Cc: 35632 <at> debbugs.gnu.org
Subject: Re: bug#35632: date Parse of '13:00 + 2 hours' Broken.
Date: Wed, 26 Jun 2019 08:53:43 -0600
tag 35632 notabug
close 35632
stop

Hello,

(sorry for the delayed reply)

On Wed, May 08, 2019 at 12:57:10PM +0100, Ralph Corderoy wrote:
> 
> Using date from coreutils 8.31-1 on Arch Linux.
> This surprised me.
> 
>     $ TZ=UTC0 /bin/date -d '1pm + 2 hours'
>     Wed  8 May 15:00:00 UTC 2019
>     $ TZ=UTC0 /bin/date -d '13:00 + 2 hours'
>     Wed  8 May 12:00:00 UTC 2019
> 
> The documentation doesn't suggest `1pm' and `13:00' are treated
> differently.  `--debug' helps.
> 
>     $ TZ=UTC0 /bin/date --debug -d '1pm + 2 hours'
>     date: parsed time part: 01:00:00pm
>     date: parsed relative part: +2 hour(s)
>     ...
>     $ TZ=UTC0 /bin/date --debug -d '13:00 + 2 hours'
>     date: parsed time part: 13:00:00 UTC+02
>     date: parsed relative part: +1 hour(s)
>     date: input timezone: parsed date/time string (+02)
>     ...
> 
> It looks like parsing is broken in the second case.

Thank you for for providing detailed output with "--debug",
makes things easier to troubleshoot.

When encountering a time string (HH:MM or HH:MM:SS) followed by a plus
sign and a number, date's parser *always* treats it as a timezone
(giving timezones higher priority than time adjustments).


> The result I wanted can also be obtained my omitting the `+'.
> 
>     $ TZ=UTC0 /bin/date -d '1pm 2 hours'
>     Wed  8 May 15:00:00 UTC 2019
>     $ TZ=UTC0 /bin/date -d '13:00 2 hours'
>     Wed  8 May 15:00:00 UTC 2019

And this is indeed one possibly solution.

Other similar issues are detailed here:
https://lists.gnu.org/archive/html/bug-coreutils/2018-10/msg00126.html

As such, I'm closing this ticket, but discussion can continue by
replying to this thread.

regards,
 - assaf





Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 26 Jun 2019 14:54:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 35632 <at> debbugs.gnu.org and Ralph Corderoy <ralph <at> inputplus.co.uk> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 26 Jun 2019 14:54: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. (Thu, 25 Jul 2019 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 268 days ago.

Previous Next


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