Allow splitting "Jahr 1920"

This commit is contained in:
2026-02-21 18:29:16 +01:00
parent 7852377a8d
commit 3f2b9091dc
2 changed files with 18 additions and 0 deletions

View File

@@ -355,6 +355,10 @@ final class NodaTimeSplitter {
}
}
if (\preg_match("/^(Jahr|Jahre)\ [0-9]{4}$/", $datum)) {
$end = \substr($datum, -4);
return new NodaSplitTime($end, $end);
}
if (\preg_match("/^[0-9]{4}\ bis\ [0-9]{4}$/", $datum)) {
$start = \substr($datum, 0, 4);
$end = \substr($datum, -4);

View File

@@ -25,6 +25,20 @@ final class NodaTimeSplitterTest extends TestCase {
public static function splittableGermanTimeNamesProvider():array {
return [
"Jahr 1920" => [
"1920",
new NodaSplitTime('1920', '1920',
start_date: '1920-01-01',
end_date: '1920-12-31'),
"1920",
],
"Jahre 1920" => [
"1920",
new NodaSplitTime('1920', '1920',
start_date: '1920-01-01',
end_date: '1920-12-31'),
"1920",
],
"1920er Jahre" => [
"1920er Jahre",
new NodaSplitTime('1920', '1929',