Fix erroneous splitting of "YYYY MMD" in Hungarian

This commit is contained in:
Joshua Ramon Enslin 2023-12-08 12:26:59 +01:00
parent 27e259072c
commit 2ab0e75111
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 7 additions and 0 deletions

View File

@ -531,6 +531,10 @@ final class NodaTimeSplitter {
if (empty($monat) and self::is_numeric((string)\substr($datum, 5, 2))) $monat = \substr($datum, 5, 2); if (empty($monat) and self::is_numeric((string)\substr($datum, 5, 2))) $monat = \substr($datum, 5, 2);
else if (empty($monat) and self::is_numeric((string)\substr($datum, 6, 2))) $monat = \substr($datum, 6, 2); else if (empty($monat) and self::is_numeric((string)\substr($datum, 6, 2))) $monat = \substr($datum, 6, 2);
// Last four characters must contain at least one space or one dot
$lastChars = substr($datum, -4);
if (str_contains($lastChars, '.') === false && str_contains($lastChars, ' ') === false) return [];
$day = self::validateDateSubstr($datum, -2); $day = self::validateDateSubstr($datum, -2);
if (empty($day)) $day = self::validateDateSubstr($datum, -3, 2); if (empty($day)) $day = self::validateDateSubstr($datum, -3, 2);
if (empty($day)) $day = self::validateDateSubstr($datum, -4, 2); if (empty($day)) $day = self::validateDateSubstr($datum, -4, 2);

View File

@ -878,6 +878,9 @@ final class NodaTimeSplitterTest extends TestCase {
$output = NodaTimeSplitter::attempt_splitting("6552cf08b0196 test tag"); $output = NodaTimeSplitter::attempt_splitting("6552cf08b0196 test tag");
self::assertEmpty($output); self::assertEmpty($output);
$output = NodaTimeSplitter::attempt_splitting("1978. július7");
self::assertEmpty($output);
$output = NodaTimeSplitter::attempt_splitting("Anfang September 1903"); $output = NodaTimeSplitter::attempt_splitting("Anfang September 1903");
self::assertEmpty($output); self::assertEmpty($output);