NB: My 1st meditation. I don't 'think' this is a SPW post - I don't have a problem, just want to share this.

In the last couple of weeks I've spent some spare time (at work) developing a nice little personal information manager. It was working fine yesterday, I did some more work on it today, and was happy to call it complete (for now), zip it up and start thinking about other things. This is where the problem struck!

I was happily using my new calendar and diary functions and wanted to skip forward and view the calendar for Feburary 2001. Suddenly - white screen (my app is CGI-based for ease of accessibility). I managed to locate the source of the problem and correct it, but it raised an interesting question...

I was using Date::Calc::Add_Delta_YMD(), specifically:
my @DateToday = Date::Calc::Today_and_Now(); # ($year,$month,$d +ay, $hour,$min,$sec) my @MonthAhead = Date::Calc::Add_Delta_YMD($DateToday[0],$DateToday[1] +,$DateToday[2],0,+1,0);
Now, this is fine if you want to work out the date say: one month from January 6 2001. But if you want to work out the date one month from January 29 2000 - it falls down (there is no February 29 2001 - or April/May/September/etc 31st). I was using strict and warnings and I didn't get an error - just a blank screen.

Luckily, I didn't need to know the exact date $x months from now, just the month, and from there I do other calculations. But what if you do? - well I suppose one way is to remember this problem and do a quick check to see if the date exists and adjust if necessary.

But, my question is this - what is the date a month from January 30th? How do you decide how to adjust for this variable? Perhaps it varies from situation to situation (TIMTOWTDI) or maybe I am being thoroughly stupid.

I would love to hear if anyone else has been stumped by such a problem.

In reply to Year /^\d+$/ bug! by $code or die

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.