Prevent noda time splitter from suggesting times with months beyond 12,

days beyond 31
This commit is contained in:
Joshua Ramon Enslin 2022-08-25 22:06:15 +02:00
parent 3c67d425fb
commit 1ed2959b62
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 16 additions and 0 deletions

View File

@ -1086,6 +1086,12 @@ final class NodaTimeSplitter {
if (!$moda) $moda = NodaTimeSplitter::is_century($datum);
if (!$moda) $moda = NodaTimeSplitter::is_decade($datum);
if (!empty($moda)) {
if ((int)$moda[2] > 12 || (int)$moda[3] > 31) {
return [];
}
}
return $moda;
}

View File

@ -593,6 +593,16 @@ final class NodaTimeSplitterTest extends TestCase {
$output = NodaTimeSplitter::attempt_splitting("Januar-Februar");
self::assertEquals($output, []);
$output = NodaTimeSplitter::attempt_splitting("13.13.2022");
self::assertEquals($output, []);
$output = NodaTimeSplitter::attempt_splitting("2022-13-13");
self::assertEquals($output, []);
$output = NodaTimeSplitter::attempt_splitting("40.10.2022");
self::assertEquals($output, []);
$output = NodaTimeSplitter::attempt_splitting("2022-10-40");
self::assertEquals($output, []);
# $output = NodaTimeSplitter::attempt_splitting("Nach 1944-1964");
# self::assertEquals($output, []);