Bugzilla – Attachment 96106 Details for
Bug 24134
Add placeholder for 2 digit years to allow autogeneration of dates in 008
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008
Bug-24134-Add-placeholder-for-2-digit-years-to-all.patch (text/plain), 5.63 KB, created by
Owen Leonard
on 2019-12-09 16:56:48 UTC
(
hide
)
Description:
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2019-12-09 16:56:48 UTC
Size:
5.63 KB
patch
obsolete
>From 0826057d6f498d917135a448770ce7d52bb85193 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 2 Dec 2019 16:42:59 +0000 >Subject: [PATCH] Bug 24134: Add placeholder for 2 digit years to allow > autogeneration of dates in 008 > >This patch modifies the code for parsing MARC framework configurations >so that the placeholder "<<YY>>" translates to a two-year date. > >To test, apply the patch and modify a framework to include placeholders. >For example, in MARC21: > > - Administration -> MARC structure -> 952 -> Edit subfields -> d > - Expand "Advanced constraints" and add a default value: > <<YYYY>> <<YY>> <<MM>> <<DD>> <<USER>> > - Save your configuration and go to Cataloging. > - Go to the add/edit items page for a record which uses the framework > you edited. > - In the "Add item" form, in the "Date aquired" field, you should see > the correct values. For example: '2019 19 12 03 Leonard' > >Perform the same test when adding an item during the Acquisitions >process (depending on your AcqCreateItem setting). > >Note that acqui/neworderempty.pl has been modified because the >placeholder-replacement code is repeated there, but I couldn't discover >how to test it (if it is used at all?) >--- > C4/Items.pm | 17 +++++++++++++++++ > acqui/neworderempty.pl | 4 +++- > cataloguing/addbiblio.pl | 4 +++- > cataloguing/additem.pl | 4 +++- > 4 files changed, 26 insertions(+), 3 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index b81fb0aa17f..ba1037e29b5 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -2398,6 +2398,23 @@ sub PrepareItemrecordDisplay { > $defaultvalue = q||; > } else { > $defaultvalue =~ s/"/"/g; >+ # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value >+ my $today_dt = dt_from_string; >+ my $year = $today_dt->strftime('%Y'); >+ my $shortyear = $today_dt->strftime('%y'); >+ my $month = $today_dt->strftime('%m'); >+ my $day = $today_dt->strftime('%d'); >+ $defaultvalue =~ s/<<YYYY>>/$year/g; >+ $defaultvalue =~ s/<<YY>>/$shortyear/g; >+ $defaultvalue =~ s/<<MM>>/$month/g; >+ $defaultvalue =~ s/<<DD>>/$day/g; >+ >+ # And <<USER>> with surname (?) >+ my $username = >+ ( C4::Context->userenv >+ ? C4::Context->userenv->{'surname'} >+ : "superlibrarian" ); >+ $defaultvalue =~ s/<<USER>>/$username/g; > } > > my $maxlength = $tagslib->{$tag}->{$subfield}->{maxlength}; >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index ab95f161474..b5ec5ace0b9 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -227,12 +227,14 @@ if ( not $ordernumber ) { # create order > > if ( $value eq '' ) { > >- # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value >+ # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value > my $today_dt = dt_from_string; > my $year = $today_dt->strftime('%Y'); >+ my $shortyear = $today_dt->strftime('%y'); > my $month = $today_dt->strftime('%m'); > my $day = $today_dt->strftime('%d'); > $value =~ s/<<YYYY>>/$year/g; >+ $value =~ s/<<YY>>/$shortyear/g; > $value =~ s/<<MM>>/$month/g; > $value =~ s/<<DD>>/$day/g; > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 00b250190a9..45c6ab83789 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -279,12 +279,14 @@ sub create_input { > if ( $value eq '' ) { > $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{}; > >- # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value >+ # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value > my $today_dt = dt_from_string; > my $year = $today_dt->strftime('%Y'); >+ my $shortyear = $today_dt->strftime('%y'); > my $month = $today_dt->strftime('%m'); > my $day = $today_dt->strftime('%d'); > $value =~ s/<<YYYY>>/$year/g; >+ $value =~ s/<<YY>>/$shortyear/g; > $value =~ s/<<MM>>/$month/g; > $value =~ s/<<DD>>/$day/g; > # And <<USER>> with surname (?) >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 2c371def289..69d309926e2 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -136,12 +136,14 @@ sub generate_subfield_form { > if ( ! defined( $value ) || $value eq '') { > $value = $subfieldlib->{defaultvalue}; > if ( $value ) { >- # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value >+ # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value > my $today_dt = dt_from_string; > my $year = $today_dt->strftime('%Y'); >+ my $shortyear = $today_dt->strftime('%y'); > my $month = $today_dt->strftime('%m'); > my $day = $today_dt->strftime('%d'); > $value =~ s/<<YYYY>>/$year/g; >+ $value =~ s/<<YY>>/$shortyear/g; > $value =~ s/<<MM>>/$month/g; > $value =~ s/<<DD>>/$day/g; > # And <<USER>> with surname (?) >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24134
:
96106
|
96113
|
105430
|
108072