Fix bug in setting names for months

This commit is contained in:
Joshua Ramon Enslin 2022-11-03 16:02:10 +01:00
parent d641b64630
commit 511304b6f2
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 41 additions and 1 deletions

View File

@ -266,7 +266,7 @@ final class NodaTimeSplitter {
);
try {
return $prefix . $fmt->format(MD_STD::strtotime("{$moda[0]}-{$moda[2]}-10 01:01:01")) . $suffix;
return $prefix . $fmt->format(MD_STD::strtotime("{$moda[0]}-{$moda[2]}-15 01:01:01")) . $suffix;
}
catch (MDInvalidInputDate $e) {
return "";

View File

@ -201,9 +201,49 @@ final class NodaTimeSplitterTest extends TestCase {
4 => "+",
5 => "",
]);
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 1217");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1217);
$output = NodaTimeSplitter::attempt_splitting("Januar 1520");
self::assertEquals($output, [
0 => "1520",
1 => "1520",
2 => "01",
3 => "00",
4 => "+",
5 => "",
]);
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 1520");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1520);
$output = NodaTimeSplitter::attempt_splitting("Januar 1001");
self::assertEquals($output, [
0 => "1001",
1 => "1001",
2 => "01",
3 => "00",
4 => "+",
5 => "",
]);
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 1001");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1001);
$output = NodaTimeSplitter::attempt_splitting("Januar 2780");
self::assertEquals($output, [
0 => "2780",
1 => "2780",
2 => "01",
3 => "00",
4 => "+",
5 => "",
]);
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 2780");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2780);
$output = NodaTimeSplitter::attempt_splitting("Nach 60er Jahre");
self::assertEquals($output, [
0 => "1970",