From 5b99304b5cc53d5ef761f7414e307c01f382fcbd Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 10 Mar 2025 03:58:45 +0100 Subject: [PATCH] Accept an additional type of hyphen / dash in time splitting --- src/NodaTimeSplitter.php | 2 +- tests/NodaTimeSplitterTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NodaTimeSplitter.php b/src/NodaTimeSplitter.php index f93ef2d..8b17108 100644 --- a/src/NodaTimeSplitter.php +++ b/src/NodaTimeSplitter.php @@ -549,7 +549,7 @@ final class NodaTimeSplitter { } // 0000-0000 - if (\preg_match("/^[0-9]{4}(\-|\/)[0-9]{4}(\.|)$/", $datum)) { + if (\preg_match("/^[0-9]{4}(\-|\/|\–)[0-9]{4}(\.|)$/", $datum)) { return new NodaSplitTime(start_year: \substr($datum, 0, 4), end_year: \substr($datum, 5, 4)); } diff --git a/tests/NodaTimeSplitterTest.php b/tests/NodaTimeSplitterTest.php index 943de86..d02f6f0 100644 --- a/tests/NodaTimeSplitterTest.php +++ b/tests/NodaTimeSplitterTest.php @@ -160,11 +160,11 @@ final class NodaTimeSplitterTest extends TestCase { "1945-2046", ], "1930–2017" => [ - "1930-2017", + "1930–2017", new NodaSplitTime('1930', '2017', start_date: '1930-01-01', end_date: '2017-12-31'), - "1930-2017", + "1930–2017", ], ];