Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: How to check if a date exists ?

by HJO (Acolyte)
on Oct 18, 2012 at 11:10 UTC ( #999706=note: print w/replies, xml ) Need Help??


in reply to Re: How to check if a date exists ?
in thread How to check if a date exists ?

Hi,

First of all thank you for your answer, secondly, you're saying that this module is in the core since 5.10, but I'm using Perl 5.8.8, so I still can use it but I have to install it first right ?

And finally, could you please "validate" my code ? :

my $s = '20121018'; my $date; eval { $date = Time::Piece->strptime("$s"); }; if ( $@ ) { die qq{Error : the date doesn't exist or is not like YYYYMMDD\ +n} } else {print qq{date OK\n}} ;

Regards

Replies are listed 'Best First'.
Re^3: How to check if a date exists ?
by james2vegas (Chaplain) on Oct 19, 2012 at 07:42 UTC
    You need a format, like "%Y%m%d" as the second parameter to strptime (I left that out in my earlier code, so my fault).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999706]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2016-12-11 01:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (168 votes). Check out past polls.