Subject: | Module dies even when on_error is 'undef' |
Hi,
I'm having errors with invalid dates causing the parse to die instead of
failing silently:
use DateTime::Format::Strptime;
my $strp = new DateTime::Format::Strptime(pattern => '%Y-%m-%d
%H:%M:%S', on_error=> 'undef');
my $date = '0000-00-00 00:00:00';
my $dt = $strp->parse_datetime($date) || print $strp->errmsg;
This dies with:
The 'month' parameter ("00") to DateTime::new did not pass the 'is
between 1 and 12' callback
at /usr/local/lib/perl5/site_perl/5.8.7/DateTime/Format/Strptime.pm
line 444
The way that D::F::S handles incorrect dates is not consistent. E.g.
replace the date line with
my $date = '1999-111-12 02:30:16';
And the code performs as expected, $strp->errmsg returns:
"24 is too large to be a month of the year."