GNU bug report logs -
#6897
date -d '1991-04-14 +1 day' fails
Previous Next
Reported by: 李嘉鹏 <lijpbasin <at> 126.com>
Date: Sun, 22 Aug 2010 19:33:02 UTC
Severity: normal
Done: Bob Proulx <bob <at> proulx.com>
Bug is archived. No further changes may be made.
Full log
Message #25 received at 6897 <at> debbugs.gnu.org (full text, mbox):
Paul Eggert writes:
>
> On 08/22/10 18:09, Alan Curry wrote:
> > There might be less occurrences of this misunderstanding if we could teach
> > date that -d 4/14/1991 is not actually a request for 4/14/1991 00:00:00, but
> > "any time that existed during the day 4/14/1991", or perhaps a more specific
> > "the first second of 4/14/1991".
> >
> > Has that been considered and rejected already, or is it just waiting for
> > someone to implement it?
>
> As far as I know nobody has ever suggested that, and it is a reasonable suggestion.
> However, it would not fix the problem in general, since in some cases there
> is no "first second of date X", even when X is valid. For example:
>
> $ TZ=Pacific/Kwajalein date -d 1993-08-20
> date: invalid date `1993-08-20'
There's nothing wrong with that error message. It's telling the truth about
1993-08-28 being an invalid date.
But TZ=Asia/Shanghai date -d '4/14/1991' says:
date: invalid date `4/14/1991'
which is a lie. 4/14/1991 is not an invalid date. It made a bad assumption
(that midnight was intended, when the user didn't ask for midnight at all)
and then reported an error caused by the bad assumption, and didn't even have
the courtesy to mention the assumption.
Bonus thought: the "date" command is misnamed. If it actually worked with
dates, it wouldn't need to attach an hour, minute, and second to everything.
It would understand 4/14/1991 as representing an entire day, and "+ 1 day"
added to it would represent the entire next day. But date doesn't work with
dates, it works with time_t's. This is not obvious to the casual user.
--
Alan Curry
This bug report was last modified 14 years and 275 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.