Bug 14922: (followup) Fix string output
authorMarc Véron <veron@veron.ch>
Wed, 7 Oct 2015 18:42:23 +0000 (20:42 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 19 Oct 2015 14:49:39 +0000 (11:49 -0300)
This patch makes YYYY MM and DD display correctly.

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as advertised

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
cataloguing/additem.pl

index 4be75f7..19279b3 100755 (executable)
@@ -129,10 +129,11 @@ sub generate_subfield_form {
         if ( ! defined( $value ) || $value eq '')  {
             $value = $subfieldlib->{defaultvalue};
             # get today date & replace YYYY, MM, DD if provided in the default value
-            my $today = dt_from_string;
-            $value =~ s/YYYY/$today->year/g;
-            $value =~ s/MM/$today->month/g;
-            $value =~ s/DD/$today->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 (($subfieldlib->{hidden} > 4) || ($subfieldlib->{hidden} <= -4));