@@ -, +, @@ $estimateddeliverydate = "$year-$month-$day"; diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 5fe2653..4434a67 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -72,17 +72,17 @@ sub dt_from_string { my $fallback_re = qr| (?\d{4}) - - (?\d{2}) + (?\d{1,2}) - - (?\d{2}) + (?\d{1,2}) |xms; if ( $date_format eq 'metric' ) { # metric format is "dd/mm/yyyy[ hh:mm:ss]" $regex = qr| - (?\d{2}) + (?\d{1,2}) / - (?\d{2}) + (?\d{1,2}) / (?\d{4}) |xms; @@ -90,9 +90,9 @@ sub dt_from_string { elsif ( $date_format eq 'us' ) { # us format is "mm/dd/yyyy[ hh:mm:ss]" $regex = qr| - (?\d{2}) + (?\d{1,2}) / - (?\d{2}) + (?\d{1,2}) / (?\d{4}) |xms; diff --git a/t/DateUtils.t b/t/DateUtils.t index 886e1d6..0877240 100755 --- a/t/DateUtils.t +++ b/t/DateUtils.t @@ -189,3 +189,8 @@ is( output_pref( { dt => $dt } ), '31/01/2015 12:34', 'dt_from_string should mat # date before 1900 $dt = dt_from_string('01/01/1900'); is( output_pref( { dt => $dt, dateonly => 1 } ), '01/01/1900', 'dt_from_string should manage date < 1900' ); + +# missing 0 +$dt = dt_from_string('1/1/2015'); +is( output_pref( { dt => $dt, dateonly => 1 } ), '01/01/2015', 'dt_from_string should generate a DT object even if 0 are missing' ); --- acqui/basket.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/acqui/basket.pl +++ a/acqui/basket.pl @@ -312,7 +312,7 @@ if ( $op eq 'delete_confirm' ) { if( $basket->{closedate} ) { my ($year, $month, $day) = ($basket->{closedate} =~ /(\d+)-(\d+)-(\d+)/); ($year, $month, $day) = Add_Delta_Days($year, $month, $day, $bookseller->{deliverytime}); - $estimateddeliverydate = "$year-$month-$day"; + $estimateddeliverydate = sprintf( "%04d-%02d-%02d", $year, $month, $day ); } # if new basket, pre-fill infos --