Fix bug in splitter causing wrong positives

This commit is contained in:
Joshua Ramon Enslin 2020-09-20 18:50:26 +02:00 committed by Stefan Rohde-Enslin
parent ce6e388866
commit 8f7df866d7

View File

@ -304,6 +304,11 @@ final class NodaTimeSplitter {
$end = "-" . substr($datum, 4, 3); $end = "-" . substr($datum, 4, 3);
return [$start, $end, "00", "00", "-"]; return [$start, $end, "00", "00", "-"];
} }
if (preg_match("/^[0-9][0-9](\-|\/)[0-9][0-9] v\. Chr\.$/", $datum)) {
$start = "-00" . substr($datum, 0, 2);
$end = "-00" . substr($datum, 3, 2);
return [$start, $end, "00", "00", "-"];
}
if (self::stri_occurs($datum, self::STOP_STRINGS_GERMAN)) { if (self::stri_occurs($datum, self::STOP_STRINGS_GERMAN)) {
return []; return [];
@ -423,7 +428,7 @@ final class NodaTimeSplitter {
$datum = self::clean_input($datum); $datum = self::clean_input($datum);
if (preg_match("/^[0-9][0-9][0-9][0-9](-|\/)[0-9][0-9][0-9][0-9]$/", $datum)) { if (preg_match("/^[0-9][0-9][0-9][0-9](\-|\/)[0-9][0-9][0-9][0-9]$/", $datum)) {
$start = substr($datum, 0, 4); $start = substr($datum, 0, 4);
$end = substr($datum, -4); $end = substr($datum, -4);
return [$start, $end, "00", "00", "+"]; return [$start, $end, "00", "00", "+"];
@ -471,11 +476,16 @@ final class NodaTimeSplitter {
$end = substr($datum, -4); $end = substr($datum, -4);
return [$start, $end, "00", "00", "+"]; return [$start, $end, "00", "00", "+"];
} }
if (preg_match("/[0-9][0-9][0-9]\-[0-9][0-9][0-9]$/", $datum)) { // Hungarian Y-m if (preg_match("/^[0-9][0-9][0-9]\-[0-9][0-9][0-9]$/", $datum)) { // Hungarian Y-m
$start = substr($datum, 0, 3); $start = substr($datum, 0, 3);
$end = substr($datum, -3); $end = substr($datum, -3);
if ($end > $start) return ["0" . $start, "0" . $end, "00", "00", "+"]; if ($end > $start) return ["0" . $start, "0" . $end, "00", "00", "+"];
} }
if (preg_match("/^[0-9][0-9]\-[0-9][0-9]$/", $datum)) { // Hungarian Y-m
$start = substr($datum, 0, 2);
$end = substr($datum, -2);
if ($end > $start) return ["00" . $start, "00" . $end, "00", "00", "+"];
}
if (preg_match("/^[0-9][0-9][0-9][0-9]$/", $datum)) { if (preg_match("/^[0-9][0-9][0-9][0-9]$/", $datum)) {