[prev in list] [next in list] [prev in thread] [next in thread] 

List:       coreutils-bug
Subject:    Re: bug in date utillity
From:       Philip Rowlands <phr () doc ! ic ! ac ! uk>
Date:       2006-07-31 13:36:42
Message-ID: Pine.LNX.4.63L.0607311429310.14022 () medusa-s2 ! doc ! ic ! ac ! uk
[Download RAW message or body]

On Mon, 31 Jul 2006, Vladislav ZItikis wrote:

> I think, I find a bug in date calculations.
> This is example for demonstration:
> -----------------------------------------------------------
>
> snaka@~$ date
> Mon Jul 31 17:12:57 MSD 2006
>
> snaka@~$ date -d "1 month ago" +"%m"
> 07
> snaka@~$ date -d "2 month ago" +"%m"
> 05
> snaka@~$
>
> ------------------------------------------------------------------
> I think, date -d "1 month ago" +"%m" must return to me '06' but not '07'

Please see section 27.6 of the date manual, "Relative items in date 
strings", which states:

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.


Cheers,
Phil



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic