I was trying to use Date::Simple to convert date from DD-MM-YYYY to ISO
standard YYYY-MM-DD,  but it produced error below because it returned undef
when the date passed is not ISO standard.

$ perl -e 'use Date::Simple (":all");$date =
Date::Simple->new("29-01-1972"); $x =  $date->as_iso;  print  "$x\n" or
"invalid\n";'
Can't call method "as_iso" on an undefined value at -e line 1.

 Based on the following two results, it's obvious the module does not
support date formats other than ISO.

perl -e 'use Date::Simple (":all");$date = Date::Simple->new("1972-01-29");
$x =  $date->as_iso;  print  "$x\n" or "invalid\n";'
1972-01-29

$ perl -e 'use Date::Simple (":all");$date = Date::Simple->new("19720129");
$x =  $date->as_iso;  print  "$x\n" or "invalid\n";'
1972-01-29

Most of the date modules on CPAN cannot do the job for me. I spent time
reading documentations but as it now stands, I have to do  this myself.

Mimi





On 24 July 2013 15:24, mimic...@gmail.com <mimic...@gmail.com> wrote:

> I'm trying to convert dates (input from user in any format) to ISO and
> check it's valid.
>
> Can someone provide an example of this using Date::Simple or Date::Manip?
>
> Mimi
>

Reply via email to