Subject: | Date_Cmp doesn't verify input parameters |
Date_Cmp does not check the return values coming back from
ParseDateString . In cases where both input strings are invalid strange
results are returned.
e.g. Date_Cmp( '1', '2' ) returns '0'
or Date_Cmp( '', '' ) returns '0' (which kind of makes sense)
I think the best approach for this would be to check the return value of
both ParseDateString calls.
here is my proposed patch:
sub Date_Cmp {
my($D1,$D2)=@_;
my($date1)=ParseDateString($D1) || croak "Invalid input: date1";
my($date2)=ParseDateString($D2) || croak "Invalid input: date2";
return $date1 cmp $date2;
}
the problem might be backwards compatibility... Could add a flag to
enabled croaking or preserve old behavior.