Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: get remaining hours

by sundialsvc4 (Abbot)
on May 06, 2013 at 13:48 UTC ( #1032291=note: print w/replies, xml ) Need Help??


in reply to get remaining hours

The CPAN library, at http://search.cpan.org, contains thousands of packages which deals with dates, such as Date::Calc, Date::Manip, or Date::Simple.

For example, click on the Date::Simple link and look at the EXAMPLES section:

use Date::Simple (); my $date = Date::Simple->new('1972-01-17'); ...

An opaque object as provided by this particular (pre-built, pre-tested) CPAN package, has among other things the ability to parse a date-string such as the one that you have, and to “do things with” the resulting date-value.   You do not have to be concerned with exactly how the magic works, because the logic has been rigorously tested (even as part of the process of installing the package on your system).   To you, that object “is a” date, and a very smart one at that.

Although this particular package deals only with dates, not hours ... have a peek now at, say, Date::Calc::Object or Date::Calc.   :-)   Truly, there is nothing having to do with dates ... no, not even in the Mayan calendar (DateTime::Calendar::Mayan), if you are so inclined, whereby you must “roll your own.”

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032291]
help
Chatterbox?
[1nickt]: Good morning Monks and Monkettes!
[1nickt]: I have encountered a small code snippet I can not decipher: if ($?) { my $status = $? >> 8; ... }

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2017-12-13 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (358 votes). Check out past polls.

    Notices?