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] Update on the Gnu date problem

[ILUG] Update on the Gnu date problem

paul at clubi.ie paul at clubi.ie
Tue Apr 10 11:51:05 IST 2007


On Tue, 10 Apr 2007, Niall O Broin wrote:

> Because I feel that 3 weeks ago does NOT always mean 3*7*24 hours 
> ago, the exception being where there has been an intervening DST 
> transition.

So what it should mean then? Your answer should be consistent for 
input time specified in one TZ (e.g. IST) and getting answer in 
another (e.g. GMT) generally..

And you'll need to think how to reword the following text from the 
coreutils manual which seems pretty clear on what 'week' means ;):

   "The unit of time displacement may be selected by the string year
    or month for moving by whole years or months. These are fuzzy units, as
    years and months are not all of equal duration. More precise units
    are fortnight which is worth 14 days, week worth 7 days, day worth
    24 hours, hour worth 60 minutes, minute or min worth 60 seconds, and
    second or sec worth one second."

> That's your view (and presumably the Gnu date maintainers). I 
> wonder is there some standards document which defines this 
> behaviour?

I doubt it, because -d appears to be a GNU extension.

> The particularly hairy answer is where you request date -d "3 weeks 
> ago 08:00" where the date returned will vary by 24 hours, depending 
> on what time of the day you run date.

Hmm, I can't reproduce that. "3 weeks ago HHMM" produces HH for me, 
regardless. Is it cause you ran date with hour of current date 
corresponding to the hour of DST change?

If so, you can apparently adjust the time used in these relative time 
modifications, so something like:

   "0800 today 3 weeks ago"

/might/ avoid that problem..

> Bottom line of course is that if you want to do reliable date 
> arithmetic or manipulation you use UTC.

Hey, the GNU Date maintainers agree with you:

   "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.

> This is something I'm well used to from working in an industry 
> where that was standard, but when you're producing information for 
> the great unwashed, they tend to like it to be related to their 
> timezone IME.

And if you printed out the timezone in your first example, you'd see 
it was..

Also, if the fine manual says 3 weeks means 3*24*7 hours exactly, the 
great unwashed might expect it to mean that.. ;).

regards,
-- 
Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
Fortune:
The universe seems neither benign nor hostile, merely indifferent.
 		-- Sagan



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