If you can afford using a module, I recommend Date::Calc. It has a check_date function that can check if any date is valid, and also a Days_in_Month function that returns the number of days in a given month.

I also recommend Date::Calc for any date/time calculations. IMHO, date/time calculations is one of those things that has been done too many times, but is always a source of errors when you try to do it yourself... From converting seconds to hours, to adding days to a date while taking into account the leap year calculations and everything, this module can simplify error-prone date/time calculations greatly.

(Geez, that sounds like a sales pitch... I'm serious about those types of calculations being error prone though. Just go through Date::Calc's POD, you'll see how many things the author took into account in the module)

In reply to Re: Re: Re: Re: Re: Calculating between times by Skylark
in thread Calculating between times by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.