check year validity and report invalid_year in $skip
[koha-bibliografija] / html.pl
diff --git a/html.pl b/html.pl
index ef041d2..84d54e2 100755 (executable)
--- a/html.pl
+++ b/html.pl
@@ -155,7 +155,12 @@ while( my $row = $sth_select_authors->fetchrow_hashref ) {
 
         if ($elt->localname eq 'controlfield') {
                        if ( $tag eq '008' ) {
-                                $biblio_year->{ $row->{biblionumber} } = $data->{year} = substr($elt->textContent, 7, 4 );
+                               my $year = substr($elt->textContent, 7, 4 );
+                               if ( $year !~ m/^\d+$/ ) {
+                                       $year = 0;
+                                       push @{ $skip->{invalid_year} }, $row->{biblionumber};
+                               }
+                               $biblio_year->{ $row->{biblionumber} } = $data->{year} = $year;
                        }
                        next;
         } elsif ($elt->localname eq 'datafield') {