I thought the category 'fun stuff' was obvious....

I take great pride in my code (even if it's sometimes wrong).

I also spent the better part of 1997 thru 1999 fixing broken mainframe date code for a living. If you want to compare a 30 year old 2 digit year problem to a 100 year old leap year problem I think there's a baby/bath-water comparison that could be made. For all you know, by 2100 the leap year rule may be changed into another exception just to prevent computer leap year problems from popping up! (if we're even using the same calendar system by then)

The code I've written here specifically uses current date +/- 1 year. Without rewriting portions of it, it will never see 1900. You, me and everything we know and believe about computers will be long since dead and turned to dust before this code ever sees 2100. So the scenario of someone using this snippet untouched for either of those years is not even a probability. That's the beauty of the 2000 'exception'.

The code as written (pending some revisions) will happily work with any birthdate of any year. You can use any number that Perl will accept for the birthdate year, it isn't even passed to a date function of any kind. There is no provision to provide any date other than the current date. To make such a modification would require more careful attention to leap years as you've suggested. It would also not be the code I wrote.

The point of my writing it was to avoid using Date::Calc. If Date::Calc were a core module I might have considered it first but it's not. There are times when you can't just pick the module of your dreams and toss it into the script.

In reply to Re^4: Calculate Age, days to next and days from last for a given birthday by ruzam
in thread Calculate Age, days to next and days from last for a given birthday by ruzam

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.