Hello,

I'm working on Data::FormValidator again. This time I'm working on adding some date validation to the core module. I'd like to make my solution scalable so it's easy to validate dates in other formats besides the ones I prefer myself.

My plan is to parse a string with a regular expression, and then feed it to Date::Calc's check_time() and check_date() functions.

I realize Date::Manip is out there as a solution that will parse most any string, but's such a beast to load.

I'm thinking of an interface like this

valid_date($your_date, 'MM/DD/YYYY'),

What I'm hoping to find is that there is easy way to start with this input and end up with ($mm,$dd,$yyyy), given the possibilities for a variety of different date formats.

As an alternative, we could use a solution that hard codes a few of the popular date formats, so the interface would look more like this:

valid_date($your_date, 'US'),

Thanks for any suggestions!

-mark


In reply to date format string -> Reg Ex solution by markjugg

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.