Do you get extra credit for using CPAN? ;)

Date::Manip is able to parse a wide variety of date formats automatically. There's half the assignment, already done.

I can't remember if Date::Manip is a core module or not. If not, you can download it from CPAN, or if you're an ActiveState user, just pull it in with PPM.

From the Date Manip POD:

In the documentation below, US formats are used, but in most (if not all) cases, a non-English equivalent will work equally well.

1. Parsing a date from any convenient format

$date = ParseDate("today"); $date = ParseDate("1st thursday in June 1992"); $date = ParseDate("05/10/93"); $date = ParseDate("12:30 Dec 12th 1880"); $date = ParseDate("8:00pm december tenth"); if (! $date) { # Error in the date }

Even if you're not allowed to use the Date::Manip module, at least look at its source code so you can see how it does all those neat tricks!


Dave


In reply to Re: More date conversion happiness by davido
in thread More date conversion happiness by ctp

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.