bug-coreutils
[Top][All Lists]
Advanced

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

Re: date bug


From: Andreas Schwab
Subject: Re: date bug
Date: Wed, 31 May 2006 23:58:23 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

"Assaf Feuerstein" <address@hidden> writes:

> As you can see the 1 month ago give me the current month instead of last
> month, and the 2 month ago give me an ok result.
> Is there a way to fix the 1 month ago that it will also work in the last
> day of the month?

Please read the section "Relative items in date strings" in the coreutils
manual:

       The fuzz in units can cause problems with relative items.  For
    example, `2003-07-31 -1 month' might evaluate to 2003-07-01, because
    2003-06-31 is an invalid date.  To determine the previous month more
    reliably, you can ask for the month before the 15th of the current
    month.  For example:

         $ date -R
         Thu, 31 Jul 2003 13:02:39 -0700
         $ date --date='-1 month' +'Last month was %B?'
         Last month was July?
         $ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!'
         Last month was June!

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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