Skip to content

Commit

Permalink
Xs added to possible date placeholders.
Browse files Browse the repository at this point in the history
  • Loading branch information
siiriylonen committed Sep 1, 2023
1 parent 987de44 commit 213f499
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/RecordManager/Finna/Record/Ead3.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,18 +774,21 @@ protected function parseDateRange($input)
$year = str_repeat($defaultYear, 4);
$month = $defaultMonth;
$day = $defaultDay;
$dateForm = [
'year' => ['uuuu', 'xxxx'],
'date' => ['uu', 'xx'],
'unit' => ['u', 'x']
];
if (!in_array($date, ['open', 'unknown'])) {
$parts = explode('-', trim($date));
if ('uuuu' === $parts[0]) {
if (in_array(strtolower($parts[0]), $dateForm['year'])) {
$unknown = true;
}
$year = str_replace('u', $defaultYear, $parts[0]);

if (isset($parts[1]) && $parts[1] !== 'uu') {
$year = str_ireplace($dateForm['unit'], $defaultYear, $parts[0]);
if (isset($parts[1]) && !in_array(strtolower($parts[1]), $dateForm['date'])) {
$month = $parts[1];
}

if (isset($parts[2]) && $parts[2] !== 'uu') {
if (isset($parts[2]) && !in_array(strtolower($parts[2]), $dateForm['date'])) {
$day = $parts[2];
}
} else {
Expand Down

0 comments on commit 213f499

Please sign in to comment.