Fix years in dates < 2 characters
Change-Id: I1f7397515586f6cdf228a776e794f46f8f9b9958
diff --git a/Changes b/Changes
index 4df9e1f..106a58c 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
-0.51 2023-05-16
+0.51 2023-08-25
- Support ICC meta.
+ - Fix date handling for years of length < 2.
0.50 2023-02-13
- Fix 'temporary-extract' configuration
diff --git a/lib/KorAP/XML/Meta/I5.pm b/lib/KorAP/XML/Meta/I5.pm
index 14999b8..7cfcffb 100644
--- a/lib/KorAP/XML/Meta/I5.pm
+++ b/lib/KorAP/XML/Meta/I5.pm
@@ -324,7 +324,21 @@
$month = 0 if $month !~ $NR_RE;
$day = 0 if $day !~ $NR_RE;
- my $date = $year ? ($year < 100 ? '20' . $year : $year) : '0000';
+ my $date = '0000';
+ if ($year) {
+ if (length($year) <= 2) {
+ # TEMP: This may change in the future!
+ if ($year < 50) {
+ $date = '20' . (length($year) == 1 ? '0' : '') . $year;
+ } else {
+ $date = '19' . $year;
+ };
+ }
+ else {
+ $date = $year;
+ };
+ };
+
$date .= length($month) == 1 ? '0' . $month : $month;
$date .= length($day) == 1 ? '0' . $day : $day;
$self->{D_pub_date} = $date;
diff --git a/t/corpus/artificial/header.xml b/t/corpus/artificial/header.xml
index a01fb11..18c196c 100644
--- a/t/corpus/artificial/header.xml
+++ b/t/corpus/artificial/header.xml
@@ -33,7 +33,7 @@
<editor>Nils Diewald</editor>
<imprint>
<publisher>Artificial articles Inc.</publisher>
- <pubDate type="year">2001</pubDate>
+ <pubDate type="year">1</pubDate>
<pubDate type="month">04</pubDate>
<pubDate type="day">02</pubDate>
<pubPlace key="DE">Mannheim</pubPlace>