Bug 17922: Use correct number of digits when replacing date placeholders

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 95e94766af)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
(cherry picked from commit fdf1f97477)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
Julian Maurice 2017-01-18 11:29:57 +01:00
parent bd29f17c65
commit ab135c07aa
2 changed files with 7 additions and 7 deletions

View File

@ -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;

View File

@ -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");