Fix edge cases in time splitter where inputs start with many digits but
are not dates
This commit is contained in:
		| @@ -514,10 +514,13 @@ final class NodaTimeSplitter { | |||||||
|         // Further code requires a year to be present, skip if none is set |         // Further code requires a year to be present, skip if none is set | ||||||
|         if (empty($year)) return []; |         if (empty($year)) return []; | ||||||
|  |  | ||||||
|  |         // Skip, if dates are too long and do not contain spaces (= no translatable names) | ||||||
|  |         if (str_contains($datum, " ") === false && strlen($datum) > 12) return []; | ||||||
|  |  | ||||||
|         foreach (self::MONTH_NAMES_HUNGARIAN as $monthVal => $monthValidNames) { |         foreach (self::MONTH_NAMES_HUNGARIAN as $monthVal => $monthValidNames) { | ||||||
|             if (self::stri_occurs($datum, $monthValidNames)) { |             if (self::stri_occurs($datum, $monthValidNames)) { | ||||||
|                 if (!empty($monat)) return []; |  | ||||||
|                 $monat = (string)$monthVal; |                 $monat = (string)$monthVal; | ||||||
|  |                 break; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -695,6 +695,9 @@ final class NodaTimeSplitterTest extends TestCase { | |||||||
|         $output = NodaTimeSplitter::attempt_splitting("6;November 1978"); |         $output = NodaTimeSplitter::attempt_splitting("6;November 1978"); | ||||||
|         self::assertEquals($output, []); |         self::assertEquals($output, []); | ||||||
|  |  | ||||||
|  |         $output = NodaTimeSplitter::attempt_splitting("65497028c51eb"); | ||||||
|  |         self::assertEquals($output, []); | ||||||
|  |  | ||||||
|         # $output = NodaTimeSplitter::attempt_splitting("Nach 1944-1964"); |         # $output = NodaTimeSplitter::attempt_splitting("Nach 1944-1964"); | ||||||
|         # self::assertEquals($output, []); |         # self::assertEquals($output, []); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user