Subject: | Bug in parsing of dates in DateTime::Split::MonthDayYear |
If you enter an invalid date the substr approach of the
DateTime::Split::MonthDayYear field type in certain circumstances fails
to correctly split the compound representation resulting in messed up
field values. Try entering 31/31/2007 for example and you'll get back
the following values in the month/day/year fields:
31
/3
1/19
The following should fix this:
--- MonthDayYear.pm 2007-09-04 13:08:34.000000000 +0200
+++ MonthDayYear.pm.fixed 2007-09-04 13:09:38.000000000 +0200
@@ -60,11 +60,12 @@
unless($date)
{
no warnings;
+ my( $month, $day, $year ) = split "/", $value;
return
{
- month => substr($value, 0, 2) || '',
- day => substr($value, 2, 2) || '',
- year => substr($value, 4, 4) || '',
+ month => $month,
+ day => $day,
+ year => $year,
}
}