Trying on for size is a figure or speech for “now see how that looks”. I never golf.

Also, please look at a module before decrying it for inflexibility.

print $date->strftime( '%e' ); # it's there if you think you need it

By truncation I was referring the fact that the calculation starts at the beginning of the month rather than from “now”. Without your explanation, 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.

Or did you think the well known formula that checks the remainers of division of the year by 4, 100 and 400 got the edge cases right? ;-)

I know it doesn't, no need for the smiley. That's why I asked the question in the first place. I'd never attempt to do any date math on my own unless I'm setting out to write a date math library. Otherwise, there's just way too many gotchas to hang yourself with in that area. And when I pick a date math library, I usually stick to DateTime because I know there was (and is) a large and painstaking effort to get every last possible edge case right, and because the API is terrifically slick.

Makeshifts last the longest.


In reply to Re^6: Finding End of Month's date by Aristotle
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.