Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: checking for valid date

by GrandFather (Sage)
on Jul 30, 2006 at 07:02 UTC ( #564595=note: print w/ replies, xml ) Need Help??


in reply to checking for valid date

There are a pile of Date manipulation modules available for Perl. The big hammer is Date::Manip. Possibly the way to validate your date string is first to chop it up assuming that the format is correct:

if ($yyyymmdd !~ /(\d{4})(\d\d)(\d\d)/) { print "Bad data string provided: $yyyymmdd\n"; return 0; } my ($year, $month, $day) = ($1, $2, $3); ...

You can then check that the year, month and day are within the expected ranges and finally validate the full date by using Date::Manip.


DWIM is Perl's answer to Gödel


Comment on Re: checking for valid date
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://564595]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2015-07-05 06:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls