Lines 1608-1613
sub _create_import_record {
Link Here
|
1608 |
return $import_record_id; |
1608 |
return $import_record_id; |
1609 |
} |
1609 |
} |
1610 |
|
1610 |
|
|
|
1611 |
sub _get_import_record_timestamp { |
1612 |
my ( $marc_record ) = @_; |
1613 |
|
1614 |
my $upload_timestamp = DateTime->now(); |
1615 |
|
1616 |
# Attempt to parse the 005 timestamp. This is a bit weird because we have to parse the |
1617 |
# tenth-of-a-second ourselves. |
1618 |
my $f005 = $marc_record->field('005'); |
1619 |
if ($f005 && $f005->data =~ /(\d{8}\d{6})\.(\d)/ ) { |
1620 |
my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d%H%M%S' ); |
1621 |
my $parsed_timestamp = $parser->parse_datetime($1); |
1622 |
|
1623 |
# We still check for success because we only did enough validation above to extract the |
1624 |
# tenth-of-a-second; the timestamp could still be some nonsense like the 50th of Jantober. |
1625 |
if ( $parsed_timestamp ) { |
1626 |
$parsed_timestamp->set_nanosecond( $2 * 100_000_000 ); |
1627 |
$upload_timestamp = $parsed_timestamp; |
1628 |
} |
1629 |
} |
1630 |
|
1631 |
return $upload_timestamp; |
1632 |
} |
1633 |
|
1611 |
sub _update_import_record_marc { |
1634 |
sub _update_import_record_marc { |
1612 |
my ($import_record_id, $marc_record, $marc_type) = @_; |
1635 |
my ($import_record_id, $marc_record, $marc_type) = @_; |
1613 |
|
1636 |
|
Lines 1656-1666
sub _update_biblio_fields {
Link Here
|
1656 |
|
1679 |
|
1657 |
my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record); |
1680 |
my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record); |
1658 |
my $dbh = C4::Context->dbh; |
1681 |
my $dbh = C4::Context->dbh; |
1659 |
# FIXME no controlnumber, originalsource |
1682 |
# FIXME no originalsource |
1660 |
# FIXME 2 - should regularize normalization of ISBN wherever it is done |
1683 |
# FIXME 2 - should regularize normalization of ISBN wherever it is done |
1661 |
$isbn =~ s/\(.*$//; |
1684 |
$isbn = C4::Koha::GetNormalizedISBN($isbn); |
1662 |
$isbn =~ tr/ -_//; |
|
|
1663 |
$isbn = uc $isbn; |
1664 |
my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ? |
1685 |
my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ? |
1665 |
WHERE import_record_id = ?"); |
1686 |
WHERE import_record_id = ?"); |
1666 |
$sth->execute($title, $author, $isbn, $issn, $import_record_id); |
1687 |
$sth->execute($title, $author, $isbn, $issn, $import_record_id); |