I'd've expected your snippet to produce June 15 when given May 16 as a start date. It's not obvious why it produces May 31 instead.

Actually, if you give it "May 16" as arguments, it will produce 31 as the answer. Why? Because the original question stated the problem as given a month and a year. So, my snippet takes a month and a year, and hence "May 16" will be the month of May in the year 16.

And if you give ParseDate incomplete dates, it assumes defaults. Like oh, the first second (00), the first minute (00), the first hour (00) and the first day (1). Exactly what I expect. BTW, Date::Time uses the same defaults.

and because the API is terrifically slick

Oh, the irony. The irony. The API specially allows chaining mutators - and your example makes use of them.


In reply to Re^7: Finding End of Month's date by Anonymous Monk
in thread Finding End of Month's date by neeraj

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.