Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Date arithmetic is not recommended

by space_monk (Chaplain)
on Oct 31, 2012 at 06:59 UTC ( #1001612=note: print w/ replies, xml ) Need Help??


in reply to WWW::Mechanize wrong month

There are lots and lots of pitfalls in date arithmetic (leap seconds, February, leap years etc), so don't mess with dates when someone else has done it for you. Browse CPAN for an appropriate Date class (Class::Date, Date::Calc etc) and use that for all your date display formatting and calculations.


Comment on Date arithmetic is not recommended
Re: Date arithmetic is not recommended
by gsparx (Novice) on Nov 02, 2012 at 22:55 UTC

    So that was the reason I was using Delta_DHMS from Date::Calc, because I wanted it to find the difference for me, but it seems like Date::Calc is not in fact ZERO based, but rather counts months from 1-12.

    I'm currently just incrementing the Month by 1 before I feed it into Delta_DHMS, and it seems to be working so far. So I should probably increment all the values in order to get the right day as well.

    Any other suggestions? Getting a date from WWW::Mechanize will mean it's ZERO based, so I wonder if I can get Date::Calc to take dates that are ZERO based rather than ONE based

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2014-09-21 12:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls