From be2da51f645faa15287dbbcf32d8caea3231f725 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 15 Oct 2015 13:50:44 +0100 Subject: [PATCH] Bug 14922: Fix day formatting if < 10 $dt->day return a single digit if < 10, we want to display it on 2 digits Signed-off-by: Jonathan Druart http://bugs.koha-community.org/show_bug.cgi?id=14950 --- tools/batchMod.pl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/batchMod.pl b/tools/batchMod.pl index af2ae4b..b31f93d 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -332,13 +332,11 @@ foreach my $tag (sort keys %{$tagslib}) { if ( !$value && $use_default_values) { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; # get today date & replace YYYY, MM, DD if provided in the default value - my $today = dt_from_string; - my $year = $today->year; - my $month = $today->month; - my $day = $today->day; - $value =~ s/YYYY/$year/g; - $value =~ s/MM/$month/g; - $value =~ s/DD/$day/g; + my $today_iso = output_pref( { dt=>dt_from_string, dateonly => 1, dateformat => 'iso' } ); + my ( $year, $month, $day ) = split ('-', $today_iso); + $value =~ s/YYYY/$year/g; + $value =~ s/MM/$month/g; + $value =~ s/DD/$day/g; } $subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4)); # testing branch value if IndependentBranches. -- 2.1.0