Prevent ambigious splitting of [0-9]{4}-[0-9]{2}

This commit is contained in:
Joshua Ramon Enslin 2025-05-06 22:32:00 +02:00
parent 057cac0f1b
commit 1051e10732
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 7 additions and 0 deletions

View File

@ -609,6 +609,12 @@ final class NodaTimeSplitter {
// Assume the end is a month
if (intval($month) < 12) {
// If the year is smaller than the second number, do not split, as either month
// or year may be meant
// Example: 1903-04
if (substr($datum, 2, 2) < 12) {
return false;
}
return new NodaSplitTime($year, $year, $month);
}
else {

View File

@ -604,6 +604,7 @@ final class NodaTimeSplitterTest extends TestCase {
"13.13.2022",
"2022-13-13",
"40.10.2022",
"1903-04",
"1903/04",
"2022-10-40",
"6;November 1978",