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

(-)a/C4/Biblio.pm (-10 / +5 lines)
Lines 2466-2481 sub _adjust_pubyear { Link Here
2466
        $retval = $1;
2466
        $retval = $1;
2467
    } elsif( $retval =~ m/(\d\d\d\d)/ && $1 > 0 ) {
2467
    } elsif( $retval =~ m/(\d\d\d\d)/ && $1 > 0 ) {
2468
        $retval = $1;
2468
        $retval = $1;
2469
    } elsif( $retval =~ m/
2469
    } elsif( $retval =~ m/(?<year>\d{1,3})[.Xx?-]/ ) {
2470
             (?<year>\d)[-]?[.Xx?]{3}
2470
        # See also bug 24674: enough to look at one unknown year char like .Xx-?
2471
            |(?<year>\d{2})[.Xx?]{2}
2471
        # At this point in code 1234? or 1234- already passed the earlier regex
2472
            |(?<year>\d{3})[.Xx?]
2472
        # Things like 2-, 1xx, 1??? are now converted to a four positions-year.
2473
            |(?<year>\d)[-]{1,3}\??
2473
        $retval = $+{year} * ( 10 ** (4-length($+{year})) );
2474
            |(?<year>\d\d)[-]{1,2}\??
2475
            |(?<year>\d{3})[-]\??
2476
    /xms ) { # the form 198-? occurred in Dutch ISBD rules
2477
        my $digits = $+{year};
2478
        $retval = $digits * ( 10 ** ( 4 - length($digits) ));
2479
    } else {
2474
    } else {
2480
        $retval = undef;
2475
        $retval = undef;
2481
    }
2476
    }
(-)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