Florian Lohoff wrote:
> usage of relative dates seems to be "strange". "Last Month" should
> definitly return a date in LAST month not just substract 28 days like
> "4 weeks ago"
> 
> [EMAIL PROTECTED]:~$ date --date "1 month ago"
> Tue Mar  1 14:35:31 CET 2005
> [EMAIL PROTECTED]:~$ date --date "4 weeks ago"
> Tue Mar  1 14:35:40 CET 2005
> [EMAIL PROTECTED]:~$ date --date "last month"
> Tue Mar  1 14:35:49 CET 2005
> [EMAIL PROTECTED]:~$ date
> Tue Mar 29 14:38:04 CEST 2005

The following text appears in the date 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!

       Also, take care when manipulating dates around clock changes such as
    daylight saving leaps.  In a few cases these have added or subtracted
    as much as 24 hours from the clock, so it is often wise to adopt
    universal time by setting the `TZ' environment variable to `UTC0'
    before embarking on calendrical calculations.

Bob

-- 
Bob Proulx <[EMAIL PROTECTED]>
http://www.proulx.com/~bob/
CP-ASEL-IA-Tailwheel-Glider

Attachment: signature.asc
Description: Digital signature

Reply via email to