bug-coreutils
[Top][All Lists]
Advanced

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

bug#6897: date -d '1991-04-14 +1 day' fails


From: Alan Curry
Subject: bug#6897: date -d '1991-04-14 +1 day' fails
Date: Mon, 23 Aug 2010 16:59:56 -0500 (GMT+5)

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





reply via email to

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