LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Bug in Gnu date

[ILUG] Bug in Gnu date

Niall O Broin niall at linux.ie
Mon Apr 9 21:50:04 IST 2007


Old hands may recall a bug I found in gnu date a few years ago,  
regarding its reporting of past dates with the -d specifier, in or  
around the time of changing to summer time (see http://mail.linux.ie/ 
pipermail/ilug/2002-April/044341.html). Well, it appears I've found  
another one, in a very similar vein.

I have a log rotation script which runs at 0:00 every day, and which  
gets yesterday's date like this in a shell script:

YESTERDAY=$(/bin/date -d yesterday "+%Y/%m%d")

and it did not behave as expected when it ran at 0:00 on the Monday  
after summer time came into effect (expected 2007/0325 - got 2007/0324)

To cut a long story short,  date -d yesterday  returns the date and  
time as it was 24 hours previously and not, as I'd expect, the date  
and time at the same time on the previous day. A similar logic  
applies to requests such as  date -d "2 days ago".

Now, I grant you, this could be regarded as a feature rather than a  
bug. However, if you do
date -d "yesterday 08:00" you should get a date string returned which  
represents yesterday at 08:00 and you normally do - but if you run  
date between 0:00 and 0:59 and the date you're querying is on the  
earlier side of the summer time transition, the day you get will be  
one day earlier than expected, and I believe that with that wording  
of the arguments, I can only mean "the date as it was at 08:00 on the  
day before today".

Any views, before I report this to the Gnu date maintainer?


Niall




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell