Subject: | Invalid _check_date when Date::Calc is not installed |
In DateTime/Format/Natural/Compat.pm, there is the following function:
sub _check_date
{
my $self = shift;
if ($Pure) {
my ($year, $month, $day) = @_;
local $@;
eval {
my $dt = $self->{datetime}->clone;
$dt->set_year($year);
$dt->set_month($month);
$dt->set_day($day);
};
return !$@;
}
else {
return check_date(@_);
}
}
This will fail set to $dt->set_month($month) when the
current day of the month doesn't exist in $month.
For example, trying to check a date of 2009-11-30 on 2009-08-31 will
fail because the date 2009-11-31 is invalid.
The fix is quite easy:
eval {
my $dt = $self->{datetime}->clone;
$dt->set( year => $year, month => $month, day => $day );
};
Thanks,
Clayton