Allow splitting of German short decade names: 20er or 1920er
This commit is contained in:
parent
91f435a2e4
commit
67cc76cff9
@ -797,13 +797,13 @@ final class NodaTimeSplitter {
|
||||
$datum = self::clean_input($datum);
|
||||
$bcBceIndicator = '+';
|
||||
|
||||
if (preg_match("/^[0-9]0(er\ Jahre|\-es\ évek|\-as\ \évek)$/", $datum)) {
|
||||
if (preg_match("/^[0-9]0(er|er\ Jahre|\-es\ évek|\-as\ \évek)$/", $datum)) {
|
||||
$start = "19" . substr($datum, 0, 2);
|
||||
$ende = (string)(intval($start) + 9);
|
||||
return [$start, $ende, "00", "00", $bcBceIndicator, ""];
|
||||
}
|
||||
|
||||
if (preg_match("/^[0-9][0-9][0-9]0(er\ Jahre|\-es\ évek|\-as\ \évek)$/", $datum)) {
|
||||
if (preg_match("/^[0-9][0-9][0-9]0(er|er\ Jahre|\-es\ évek|\-as\ \évek)$/", $datum)) {
|
||||
$start = substr($datum, 0, 4);
|
||||
$ende = (string)(intval($start) + 9);
|
||||
return [$start, $ende, "00", "00", $bcBceIndicator, ""];
|
||||
|
@ -120,6 +120,18 @@ final class NodaTimeSplitterTest extends TestCase {
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("20er");
|
||||
self::assertEquals($output, [
|
||||
0 => "1920",
|
||||
1 => "1929",
|
||||
2 => "00",
|
||||
3 => "00",
|
||||
4 => "+",
|
||||
5 => "",
|
||||
]);
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("1920er Jahre");
|
||||
self::assertEquals($output, [
|
||||
0 => "1920",
|
||||
|
Loading…
Reference in New Issue
Block a user