From a636f2223cec1c190b7379529eba88c8c584ab70 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 28 Oct 2015 08:41:19 +0000 Subject: [PATCH] Bug 14931: (qa followu-up) small improvements - Avoid 1 call to dt_from_string in some cases - Do not use $_ Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- admin/aqcontract.pl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl index 8f6bf3063e..a191cd827a 100755 --- a/admin/aqcontract.pl +++ b/admin/aqcontract.pl @@ -94,10 +94,12 @@ elsif ( $op eq 'add_validate' ) { my $is_a_modif = $input->param("is_a_modif"); my $contractstart_dt = eval { dt_from_string( $input->param('contractstartdate') ); }; - $contractstart_dt = dt_from_string if ( ! $contractstart_dt ); - my $contractend_dt = eval { dt_from_string( $input->param('contractenddate') ); }; - $contractend_dt = dt_from_string if ( ! $contractend_dt ); + unless ( $contractstart_dt and $contractend_dt ) { + my $today = dt_from_string; + $contractstart_dt ||= $today; + $contractend_dt ||= $today; + } if ( $is_a_modif ) { ModContract({ @@ -161,9 +163,9 @@ if ( $op eq 'list' ) { my @contracts = @{GetContracts( { booksellerid => $booksellerid } )}; # format dates - for ( @contracts ) { - $$_{contractstartdate} = output_pref({ dt => dt_from_string( $$_{contractstartdate} ), dateonly => 1 }); - $$_{contractenddate} = output_pref({ dt => dt_from_string( $$_{contractenddate} ), dateonly => 1 }), + for my $contract ( @contracts ) { + $contract->{contractstartdate} = output_pref({ dt => dt_from_string( $contract->{contractstartdate} ), dateonly => 1 }); + $contract->{contractenddate} = output_pref({ dt => dt_from_string( $contract->{contractenddate} ), dateonly => 1 }), } $template->param(loop => \@contracts); -- 2.39.5