Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Time / Date Arithmetic Module Recommendations

by GrandFather (Saint)
on Oct 09, 2008 at 03:33 UTC ( [id://716122]=note: print w/replies, xml ) Need Help??


in reply to Time / Date Arithmetic Module Recommendations

The kitchen sink module is Date::Manip. It's pretty up front about where and when you should use it and why you might not - see the 'SHOULD I USE DATE::MANIP' section in the docs.

use strict; use warnings; use Date::Manip; Date_Init ('DateFormat = NZ', 'TZ = NZST'); my $today = ParseDate ('today'); DateCalc ($today, '25 december ' . UnixDate ($today, '%Y')) =~ /\d+:\d ++:(\d+):(\d+)/; print $1 * 7 + $2, ' sleeps until Xmas';

Prints:

76 sleeps until Xmas

On most *nix boxes you shouldn't need the Date_Init, but you will need it on most Windows boxes. Your time zone may be different than mine too. ;)

<p.Update updated for children.


Perl reduces RSI - it saves typing

Replies are listed 'Best First'.
Re^2: Time / Date Arithmetic Module Recommendations
by ikegami (Patriarch) on Oct 09, 2008 at 03:42 UTC

    76 days until Xmas

    At the time of our postings, there were 78 days to Christmas in the US and 77 days to Christmas in NZ. I think you aren't counting partial days. On the Dec 20th, one says it's five days to Christmas.

      Actually one tells one's children: "it is five sleeps until Christmas" so gaps between pickets is more appropriate than pickets in this case. ;)


      Perl reduces RSI - it saves typing
Re^2: Time / Date Arithmetic Module Recommendations
by ikegami (Patriarch) on Oct 09, 2008 at 04:05 UTC
    You get odd results for Dec 26 .. Dec 31.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://716122]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-20 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found