Bugzilla – Attachment 66549 Details for
Bug 11046
Better handling of uncertain years for publicationyear/copyrightdate
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11046: Better handling of uncertain years for publicationyear
Bug-11046-Better-handling-of-uncertain-years-for-p.patch (text/plain), 3.15 KB, created by
Marcel de Rooy
on 2017-08-28 08:23:18 UTC
(
hide
)
Description:
Bug 11046: Better handling of uncertain years for publicationyear
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-08-28 08:23:18 UTC
Size:
3.15 KB
patch
obsolete
>From 98f0d2bc922c50701288e1fc111a1b82a9192279 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 25 Aug 2017 07:39:16 +0200 >Subject: [PATCH] Bug 11046: Better handling of uncertain years for > publicationyear >Content-Type: text/plain; charset=utf-8 > >This patch makes it possible that uncertain year like 18.. or 197x are >converted to 1800 or 1970 in Koha field copyrightdate (MARC21) or >publicationyear (UNIMARC). (The corresponding MARC record will not be >changed obviously.) > >This change will allow for better results when sorting search results or >list contents on copyrightdate. Currently, things like 18.. will sort >together with zero. > >Note: The regex now allows four possible uncertain year markers: x or X, >question mark or dot. > >Test plan: >[1] Run t/db_dependent/Biblio/TransformMarcToKoha.t >[2] Edit a biblio record. Save 18.. into 260c. Check biblio.copyrightdate. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Biblio.pm | 7 ++++--- > t/db_dependent/Biblio/TransformMarcToKoha.t | 15 ++++++++++++++- > 2 files changed, 18 insertions(+), 4 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 5ffb52b..bc1eb5b 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2694,10 +2694,11 @@ sub _adjust_pubyear { > # modify return value to keep only the 1st year found > if( $retval =~ m/c(\d\d\d\d)/ and $1 > 0 ) { # search cYYYY first > $retval = $1; >- } else { >- # if no cYYYY, get the 1st date. >- $retval =~ m/(\d\d\d\d)/; >+ } elsif( $retval =~ m/(\d\d\d\d)/ && $1 > 0 ) { > $retval = $1; >+ } elsif( $retval =~ m/(\d)[.Xx?]{3}|(\d\d)[.Xx?]{2}|(\d{3})[.Xx?]/ ) { >+ my $digits = $1 || $2 || $3; >+ $retval = $digits * ( 10 ** ( 4 - length($digits) )); > } > return $retval; > } >diff --git a/t/db_dependent/Biblio/TransformMarcToKoha.t b/t/db_dependent/Biblio/TransformMarcToKoha.t >index f47632d..3a47c56 100644 >--- a/t/db_dependent/Biblio/TransformMarcToKoha.t >+++ b/t/db_dependent/Biblio/TransformMarcToKoha.t >@@ -19,7 +19,7 @@ > # with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 2; >+use Test::More tests => 3; > use MARC::Record; > > use t::lib::Mocks; >@@ -93,6 +93,19 @@ subtest 'Multiple mappings for one kohafield' => sub { > '3a | 51', 'TransformMarcToKohaOneField returns biblio.field1' ); > }; > >+subtest 'Testing _adjust_pubyear' => sub { >+ plan tests => 8; >+ >+ is( C4::Biblio::_adjust_pubyear('2004 c2000 2007'), 2000, 'First cYEAR' ); >+ is( C4::Biblio::_adjust_pubyear('2004 2000 2007'), 2004, 'First year' ); >+ is( C4::Biblio::_adjust_pubyear('18xx 1900'), 1900, '1900 has priority over 18xx' ); >+ is( C4::Biblio::_adjust_pubyear('18xx'), 1800, '18xx on its own' ); >+ is( C4::Biblio::_adjust_pubyear('197X'), 1970, '197X on its own' ); >+ is( C4::Biblio::_adjust_pubyear('1...'), 1000, '1... on its own' ); >+ is( C4::Biblio::_adjust_pubyear('12?? 13xx'), 1200, '12?? first' ); >+ is( C4::Biblio::_adjust_pubyear('12? 1x'), '12? 1x', 'Too short' ); >+}; >+ > # Cleanup > Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); > $schema->storage->txn_rollback; >-- >2.1.4
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 11046
:
66549
|
66552
|
68349
|
68350
|
70235
|
70236
|
70394