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

Re: Bug in command date?



On Wed, May 04, 2005 at 10:45:06AM +0200, richard.mouli@axa.be wrote:
> That my first post in this mailing list. Please note I am not subscribed and
> I would like to get your replies sent back to me, thanks.

It helps if you set the Mail-Followup-To header in your email program
if possible. If that's not possible it helps to get a better email
program. ;) I'll put that header in now and see if that helps.

Putting yourself in a Cc: field may help as well.

> I recently wrote scripts that relies on relative dates (they do "intensive"
> date manipulations). I encountered the following problem:
> #: date -d "today -1 week"
> Wed Apr 27 09:54:18 CEST 2005
> #: date -d "today - 1 week"
> Wed May 11 09:54:22 CEST 2005	
> 
> What seems to be the same (note the space between the dash and the one) does
> not report the same result!

What *seems* to be the same is actually *not* the same. Note the space
between the dash and the one. That is a difference so it does not
report the same result! :)

See the info manual from coreutils.info, Node: General date syntax.  I
reached it via 'info date' -> Options for date -> Date input
formats. It says there:

"Hyphens not followed by a digit are currently ignored."

So in practice your first command calculates the current date minus
one week:

#: date -d "today -1 week"

and your second command calculates the current date plus one week:

#: date -d "today 1 week"

> Should this be reported as a bug (and how)?

It's not a bug; it is the behaviour described in the docs. If this
would be a real bug, I would recommend the reportbug tool from package
reportbug.

HTH,

-- 
Maurits van Rees | http://maurits.vanrees.org/ [Dutch/Nederlands] 
Public GnuPG key: keyserver.net ID 0x1735C5C2
"Let your advance worrying become advance thinking and planning."
 - Winston Churchill

Attachment: signature.asc
Description: Digital signature


Reply to: