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

(-)a/C4/Biblio.pm (-10 / +5 lines)
Lines 2461-2476 sub _adjust_pubyear { Link Here
2461
        $retval = $1;
2461
        $retval = $1;
2462
    } elsif( $retval =~ m/(\d\d\d\d)/ && $1 > 0 ) {
2462
    } elsif( $retval =~ m/(\d\d\d\d)/ && $1 > 0 ) {
2463
        $retval = $1;
2463
        $retval = $1;
2464
    } elsif( $retval =~ m/
2464
    } elsif( $retval =~ m/(?<year>\d{1,3})[.Xx?-]/ ) {
2465
             (?<year>\d)[-]?[.Xx?]{3}
2465
        # See also bug 24674: enough to look at one unknown year char like .Xx-?
2466
            |(?<year>\d{2})[.Xx?]{2}
2466
        # At this point in code 1234? or 1234- already passed the earlier regex
2467
            |(?<year>\d{3})[.Xx?]
2467
        # Things like 2-, 1xx, 1??? are now converted to a four positions-year.
2468
            |(?<year>\d)[-]{1,3}\??
2468
        $retval = $+{year} * ( 10 ** (4-length($+{year})) );
2469
            |(?<year>\d\d)[-]{1,2}\??
2470
            |(?<year>\d{3})[-]\??
2471
    /xms ) { # the form 198-? occurred in Dutch ISBD rules
2472
        my $digits = $+{year};
2473
        $retval = $digits * ( 10 ** ( 4 - length($digits) ));
2474
    } else {
2469
    } else {
2475
        $retval = undef;
2470
        $retval = undef;
2476
    }
2471
    }
(-)a/t/db_dependent/Biblio/TransformMarcToKoha.t (-12 / +12 lines)
Lines 94-100 subtest 'Multiple mappings for one kohafield' => sub { Link Here
94
};
94
};
95
95
96
subtest 'Testing _adjust_pubyear' => sub {
96
subtest 'Testing _adjust_pubyear' => sub {
97
    plan tests => 17;
97
    plan tests => 18;
98
98
99
    is( C4::Biblio::_adjust_pubyear('2004 c2000 2007'), 2000, 'First cYEAR' );
99
    is( C4::Biblio::_adjust_pubyear('2004 c2000 2007'), 2000, 'First cYEAR' );
100
    is( C4::Biblio::_adjust_pubyear('2004 2000 2007'), 2004, 'First year' );
100
    is( C4::Biblio::_adjust_pubyear('2004 2000 2007'), 2004, 'First year' );
Lines 103-118 subtest 'Testing _adjust_pubyear' => sub { Link Here
103
    is( C4::Biblio::_adjust_pubyear('197X'), 1970, '197X 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' );
104
    is( C4::Biblio::_adjust_pubyear('1...'), 1000, '1... on its own' );
105
    is( C4::Biblio::_adjust_pubyear('12?? 13xx'), 1200, '12?? first' );
105
    is( C4::Biblio::_adjust_pubyear('12?? 13xx'), 1200, '12?? first' );
106
    is( C4::Biblio::_adjust_pubyear('12? 1x'), undef, 'Too short return nothing as data must be int' );
106
    is( C4::Biblio::_adjust_pubyear('12? 1x'), 1200, '12? first' );
107
    is( C4::Biblio::_adjust_pubyear('198-'), '1980', '198-' );
107
    is( C4::Biblio::_adjust_pubyear('198-'),  1980, '198-' );
108
    is( C4::Biblio::_adjust_pubyear('19--'), '1900', '19--' );
108
    is( C4::Biblio::_adjust_pubyear('19--'),  1900, '19--' );
109
    is( C4::Biblio::_adjust_pubyear('19-'),  '1900', '19-' );
109
    is( C4::Biblio::_adjust_pubyear('19-'),   1900, '19-' );
110
    is( C4::Biblio::_adjust_pubyear('2---'), '2000', '2---' );
110
    is( C4::Biblio::_adjust_pubyear('1-'),    1000, '1-' );
111
    is( C4::Biblio::_adjust_pubyear('2--'),  '2000', '2--' );
111
    is( C4::Biblio::_adjust_pubyear('2xxx'),  2000, '2xxx' );
112
    is( C4::Biblio::_adjust_pubyear('2-'),   '2000', '2-' );
112
    is( C4::Biblio::_adjust_pubyear('2xx'),   2000, '2xx' );
113
    is( C4::Biblio::_adjust_pubyear('198-?'), '1980', '198-?' );
113
    is( C4::Biblio::_adjust_pubyear('2x'),    2000, '2x' );
114
    is( C4::Biblio::_adjust_pubyear('1981-'), '1981', 'Date range returns first date' );
114
    is( C4::Biblio::_adjust_pubyear('198-?'), 1980, '198-?' );
115
    is( C4::Biblio::_adjust_pubyear('broken'), undef, 'Non-matchign data returns nothing as the field must be int' );
115
    is( C4::Biblio::_adjust_pubyear('1981-'), 1981, 'Date range returns first date' );
116
    is( C4::Biblio::_adjust_pubyear('broken'), undef, 'Non-matching data' );
116
};
117
};
117
118
118
subtest 'Test repeatable subfields' => sub {
119
subtest 'Test repeatable subfields' => sub {
119
- 

Return to bug 24674