From 48f3bd2c3fc05cb42419c952bafe874f4b68d3bd Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sun, 27 Sep 2020 12:36:34 +0200 Subject: [PATCH] Allow splitting international dates (2020-12-20) --- src/NodaTimeSplitter.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NodaTimeSplitter.php b/src/NodaTimeSplitter.php index a3fb05e..76c2f33 100644 --- a/src/NodaTimeSplitter.php +++ b/src/NodaTimeSplitter.php @@ -523,6 +523,15 @@ final class NodaTimeSplitter { $day = "0" . substr($datum, 0, 1); return [$start, $start, $month, $day, "+", ""]; } + + // Intl': 2020-12-20 + if (preg_match("/^[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]$/", $datum)) { // German Y-m + $start = substr($datum, 0, 4); + $month = substr($datum, 5, 2); + $day = substr($datum, 8, 2); + return [$start, $start, $month, $day, "+", ""]; + } + // German MM.JJJJ if (preg_match("/^[0-9][0-9]\.[0-9][0-9][0-9][0-9]$/", $datum)) { // German Y-m $start = substr($datum, 3, 4); $month = substr($datum, 0, 2); @@ -543,6 +552,8 @@ final class NodaTimeSplitter { $endDigits = substr($datum, 5, 2); if (intval($endDigits) > 12) return [$start, substr($datum, 0, 2) . $endDigits, "00", "00", "+", ""]; } + + // 01.01.1920-31.12.1930 if (preg_match("/^01\.01\.[0-9][0-9][0-9][0-9]\-31\.12\.[0-9][0-9][0-9][0-9]$/", $datum)) { // Hungarian Y-m $start = substr($datum, 6, 4); $end = substr($datum, -4);