Trying it for size? Your fragment, without the use statement, uses 87 non-whitespace characters characters. Mine can be reduced to:
print UnixDate DateCalc("@ARGV", "+1m -1d"), "%e";
for 46 non-whitespace characters, while it even takes an argument (yours only does the current month). So. size-wise, you lose (unless you want to the longest solution....).

Whether something is intuitive or not is a subjective thing. The output format may not be very intuitive, it's far more flexible (it could easily be changed to, say "The answer to the question is %e". The "%e" directive of UnixDate is exactly the same as the one of strftime.

As for the implicite truncation not being obvious, I fully agree with that as well. It isn't obvious to me either. In fact, I've no idea what truncation you are referring to.

BTW, I'm pretty convinced I'd get all the edge cases correctly when doing a look-up table. How the lookup-table would look like strongly depends on the edges. (Which years, which calendar, which country, etc). 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? ;-)


In reply to Re^5: 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.