bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8648: bug in date?


From: Jim Meyering
Subject: bug#8648: bug in date?
Date: Wed, 11 May 2011 08:00:33 +0200

tag 8648 + notabug
close 8648
thanks

Ondrej Vasik wrote:
> On Tue, 2011-05-10 at 16:36 -0700, Turner, Neil wrote:
>> Maybe found a bug in date...  the following command:
>>
>> $ date --date="yesterday 00:00 +1 day"
>> Mon May  9 16:59:00 PDT 2011
>>
>> The date as I type this is May 10th... so I was expecting the output to be:
>> Tues May  10 00:00:00 PDT 2011
>
> First of all, please always report the version of coreutils where you
> experience the unexpected behaviour.
>
> However - it is a tricky thing - you are human, you know what you have
> meant by +1 ... but flex getdate parser is not a human - and it simply
> parses the date format. In this case date format expects +1 is timezone
> (and because I see the offset of 1 minute, I think you have quite old
> version of coreutils). +1 is then implicit for the relative time offset
> (you may consider date --date="yesterday 00:00 +3 day" to be even more
> "buggy"). Not too much to do, date parser is very fragile and you will
> always have this kind of disambiguations there. So there is only one
> hint, make the format as complete as possible (date time timezone
> offset)...
>
> With `date --date="yesterday 00:00 PDT +1 day"` you should get the date
> you expected.

Thanks for the report, Neil, and for replying, Ondřej.

Neil, if you run "info date example", you'll see pretty many examples.
There are some here, too:
http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e

BTW, simply removing the "+" should make date do what you
want most of the time:

  $ date --date="yesterday 00:00 1 day"

However, that may well fail around DST changes (as explained
in detail via that FAQ), so you should use noon rather than midnight:

  $ date --date="yesterday 12:00 1 day"

P.S. I've closed this ticket but you're welcome to continue discussing
and even to reopen it if I've missed something.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]