View | Details | Raw Unified | Return to bug 11046
Collapse All | Expand All

(-)a/C4/Biblio.pm (-3 / +4 lines)
Lines 2694-2703 sub _adjust_pubyear { Link Here
2694
    # modify return value to keep only the 1st year found
2694
    # modify return value to keep only the 1st year found
2695
    if( $retval =~ m/c(\d\d\d\d)/ and $1 > 0 ) { # search cYYYY first
2695
    if( $retval =~ m/c(\d\d\d\d)/ and $1 > 0 ) { # search cYYYY first
2696
        $retval = $1;
2696
        $retval = $1;
2697
    } else {
2697
    } elsif( $retval =~ m/(\d\d\d\d)/ && $1 > 0 ) {
2698
        # if no cYYYY, get the 1st date.
2699
        $retval =~ m/(\d\d\d\d)/;
2700
        $retval = $1;
2698
        $retval = $1;
2699
    } elsif( $retval =~ m/(\d)[.Xx?]{3}|(\d\d)[.Xx?]{2}|(\d{3})[.Xx?]/ ) {
2700
        my $digits = $1 || $2 || $3;
2701
        $retval = $digits * ( 10 ** ( 4 - length($digits) ));
2701
    }
2702
    }
2702
    return $retval;
2703
    return $retval;
2703
}
2704
}
(-)a/t/db_dependent/Biblio/TransformMarcToKoha.t (-2 / +14 lines)
Lines 19-25 Link Here
19
# with Koha; if not, see <http://www.gnu.org/licenses>.
19
# with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 2;
22
use Test::More tests => 3;
23
use MARC::Record;
23
use MARC::Record;
24
24
25
use t::lib::Mocks;
25
use t::lib::Mocks;
Lines 93-98 subtest 'Multiple mappings for one kohafield' => sub { Link Here
93
        '3a | 51', 'TransformMarcToKohaOneField returns biblio.field1' );
93
        '3a | 51', 'TransformMarcToKohaOneField returns biblio.field1' );
94
};
94
};
95
95
96
subtest 'Testing _adjust_pubyear' => sub {
97
    plan tests => 8;
98
99
    is( C4::Biblio::_adjust_pubyear('2004 c2000 2007'), 2000, 'First cYEAR' );
100
    is( C4::Biblio::_adjust_pubyear('2004 2000 2007'), 2004, 'First year' );
101
    is( C4::Biblio::_adjust_pubyear('18xx 1900'), 1900, '1900 has priority over 18xx' );
102
    is( C4::Biblio::_adjust_pubyear('18xx'), 1800, '18xx on its own' );
103
    is( C4::Biblio::_adjust_pubyear('197X'), 1970, '197X on its own' );
104
    is( C4::Biblio::_adjust_pubyear('1...'), 1000, '1... on its own' );
105
    is( C4::Biblio::_adjust_pubyear('12?? 13xx'), 1200, '12?? first' );
106
    is( C4::Biblio::_adjust_pubyear('12? 1x'), '12? 1x', 'Too short' );
107
};
108
96
# Cleanup
109
# Cleanup
97
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
110
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
98
$schema->storage->txn_rollback;
111
$schema->storage->txn_rollback;
99
- 

Return to bug 11046