Bug 17922: Use correct number of digits when replacing date placeholders
authorJulian Maurice <julian.maurice@biblibre.com>
Wed, 18 Jan 2017 10:29:57 +0000 (11:29 +0100)
committerJulian Maurice <julian.maurice@biblibre.com>
Thu, 9 Feb 2017 09:35:59 +0000 (10:35 +0100)
This patch also fixes a typo ("<<MM><" should be "<<MM>>")

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 95e94766af653de4bc721af64981140cacecf567)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
(cherry picked from commit fdf1f974770247dc4b8decfb3318e31b940be48d)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

cataloguing/addbiblio.pl
cataloguing/additem.pl

index 7cddb2f..2267bd5 100755 (executable)
@@ -296,9 +296,9 @@ sub create_input {
 
         # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value
         my $today_dt = dt_from_string;
-        my $year = $today_dt->year;
-        my $month = $today_dt->month;
-        my $day = $today_dt->day;
+        my $year = $today_dt->strftime('%Y');
+        my $month = $today_dt->strftime('%m');
+        my $day = $today_dt->strftime('%d');
         $value =~ s/<<YYYY>>/$year/g;
         $value =~ s/<<MM>>/$month/g;
         $value =~ s/<<DD>>/$day/g;
index b9e44c4..9fd8c9c 100755 (executable)
@@ -130,11 +130,11 @@ sub generate_subfield_form {
             $value = $subfieldlib->{defaultvalue};
             # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value
             my $today_dt = dt_from_string;
-            my $year = $today_dt->year;
-            my $month = $today_dt->month;
-            my $day = $today_dt->day;
+            my $year = $today_dt->strftime('%Y');
+            my $month = $today_dt->strftime('%m');
+            my $day = $today_dt->strftime('%d');
             $value =~ s/<<YYYY>>/$year/g;
-            $value =~ s/<<MM></$month/g;
+            $value =~ s/<<MM>>/$month/g;
             $value =~ s/<<DD>>/$day/g;
             # And <<USER>> with surname (?)
             my $username=(C4::Context->userenv?C4::Context->userenv->{'surname'}:"superlibrarian");