FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 05-31-2010, 05:34 PM
T o n g
 
Default date bug?

Hi,

Please take a look at the following, do you think it is bug of date?

$ date
Mon May 31 13:26:13 EDT 2010

$ date --date='1 month ago'
Sat May 1 13:24:20 EDT 2010

$ date --date='last month'
Sat May 1 11:09:21 EDT 2010

$ date --date='-1 month'
Sat May 1 13:26:49 EDT 2010

All above should give me some time in April, IMHO. (please disregard the
time, I am copying/pasting from my execution history)

Same problem with "next month":

$ date --date='+1 month'
Thu Jul 1 13:29:23 EDT 2010

$ date --date='next month'
Thu Jul 1 11:07:31 EDT 2010

I was hoping to get June.

Is it a bug, or there are other ways to get the correct answer?

Thanks

--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: hu0ruk$3l2$1@dough.gmane.org">http://lists.debian.org/hu0ruk$3l2$1@dough.gmane.org
 
Old 05-31-2010, 05:44 PM
Camaleón
 
Default date bug?

On Mon, 31 May 2010 17:34:12 +0000, T o n g wrote:

> Please take a look at the following, do you think it is bug of date?

(...)

> $ date --date='next month'
> Thu Jul 1 11:07:31 EDT 2010
>
> I was hoping to get June.

But June has not "31 days" so the closest is indeed "1st July" ;-)

> Is it a bug, or there are other ways to get the correct answer?

It's a "feature" when playing with relative time :-)

***
info date (Relative items in date strings)

(...)

When a relative item causes the resulting date to cross a boundary
where the clocks were adjusted, typically for daylight saving time, the
resulting date and time are adjusted accordingly.

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:
***

Greetings,

--
Camaleón


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: pan.2010.05.31.17.44.28@gmail.com">http://lists.debian.org/pan.2010.05.31.17.44.28@gmail.com
 

Thread Tools




All times are GMT. The time now is 06:27 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org