Fix another edge case in time splitter
This commit is contained in:
parent
7ef05a55c5
commit
4582f6a697
|
@ -507,7 +507,7 @@ final class NodaTimeSplitter {
|
||||||
if (strlen($datum) <= 9) return [];
|
if (strlen($datum) <= 9) return [];
|
||||||
|
|
||||||
// The year is only parse-able if it is a four digit year at the start
|
// The year is only parse-able if it is a four digit year at the start
|
||||||
if (self::is_numeric((string)\substr($datum, 0, 4))) {
|
if (self::is_numeric((string)\substr($datum, 0, 4)) && substr($datum, 4, 1) === '.') {
|
||||||
$year = \substr($datum, 0, 4);
|
$year = \substr($datum, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1114,11 +1114,21 @@ final class NodaTimeSplitter {
|
||||||
public static function attempt_splitting(string $datum):array {
|
public static function attempt_splitting(string $datum):array {
|
||||||
|
|
||||||
$moda = NodaTimeSplitter::is_timespan($datum);
|
$moda = NodaTimeSplitter::is_timespan($datum);
|
||||||
if (!$moda) $moda = NodaTimeSplitter::is_incomplete_date($datum);
|
if (!$moda) {
|
||||||
if (!$moda) $moda = NodaTimeSplitter::is_valid_date($datum);
|
$moda = NodaTimeSplitter::is_incomplete_date($datum);
|
||||||
if (!$moda) $moda = NodaTimeSplitter::is_valid_date_hungarian($datum);
|
}
|
||||||
if (!$moda) $moda = NodaTimeSplitter::is_century($datum);
|
if (!$moda) {
|
||||||
if (!$moda) $moda = NodaTimeSplitter::is_decade($datum);
|
$moda = NodaTimeSplitter::is_valid_date($datum);
|
||||||
|
}
|
||||||
|
if (!$moda) {
|
||||||
|
$moda = NodaTimeSplitter::is_valid_date_hungarian($datum);
|
||||||
|
}
|
||||||
|
if (!$moda) {
|
||||||
|
$moda = NodaTimeSplitter::is_century($datum);
|
||||||
|
}
|
||||||
|
if (!$moda) {
|
||||||
|
$moda = NodaTimeSplitter::is_decade($datum);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($moda)) {
|
if (!empty($moda)) {
|
||||||
if ((int)$moda[2] > 12 || (int)$moda[3] > 31) {
|
if ((int)$moda[2] > 12 || (int)$moda[3] > 31) {
|
||||||
|
|
|
@ -699,6 +699,8 @@ final class NodaTimeSplitterTest extends TestCase {
|
||||||
|
|
||||||
$output = NodaTimeSplitter::attempt_splitting("65497028c51eb");
|
$output = NodaTimeSplitter::attempt_splitting("65497028c51eb");
|
||||||
self::assertEquals($output, []);
|
self::assertEquals($output, []);
|
||||||
|
$output = NodaTimeSplitter::attempt_splitting("6552cf08b0196 test tag");
|
||||||
|
self::assertEquals($output, []);
|
||||||
|
|
||||||
# $output = NodaTimeSplitter::attempt_splitting("Nach 1944-1964");
|
# $output = NodaTimeSplitter::attempt_splitting("Nach 1944-1964");
|
||||||
# self::assertEquals($output, []);
|
# self::assertEquals($output, []);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user