Handle Jhdt as a form of century in time splitter

Close #9
This commit is contained in:
Joshua Ramon Enslin 2022-03-12 19:32:28 +01:00
parent 3001976b1b
commit b3f7845023
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 50 additions and 1 deletions

View File

@ -903,7 +903,7 @@ final class NodaTimeSplitter {
$bcBceIndicator = '+'; $bcBceIndicator = '+';
// 17. Jahrhundert // 17. Jahrhundert
if (\preg_match("/^[0-9]{2}\.\ (Jh\.|Jahrhundert|sz|század)$/", $datum)) { if (\preg_match("/^[0-9]{2}\.\ (Jh\.|Jhd(|\.)|Jhdt(|\.)|Jahrhundert|sz|század)$/", $datum)) {
if ($centuryNo = \intval(\substr($datum, 0, 2))) { if ($centuryNo = \intval(\substr($datum, 0, 2))) {
$centuryNo--; $centuryNo--;
return [(string)$centuryNo . "01", \strval($centuryNo + 1) . "00", "00", "00", $bcBceIndicator, ""]; return [(string)$centuryNo . "01", \strval($centuryNo + 1) . "00", "00", "00", $bcBceIndicator, ""];

View File

@ -7,6 +7,7 @@
declare(strict_types = 1); declare(strict_types = 1);
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
require_once __DIR__ . "/../src/NodaTimeSplitter.php"; require_once __DIR__ . "/../src/NodaTimeSplitter.php";
require_once __DIR__ . "/../src/NodaTimeAutotranslater.php";
require_once __DIR__ . "/../../MD_STD/src/MD_STD.php"; require_once __DIR__ . "/../../MD_STD/src/MD_STD.php";
/** /**
@ -277,6 +278,54 @@ final class NodaTimeSplitterTest extends TestCase {
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "2000-1901 v. Chr."); self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "2000-1901 v. Chr.");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1950); self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1950);
$output = NodaTimeSplitter::attempt_splitting("20. Jh.");
self::assertEquals($output, [
0 => "1901",
1 => "2000",
2 => "00",
3 => "00",
4 => "+",
5 => "",
]);
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
$output = NodaTimeSplitter::attempt_splitting("20. Jhd.");
self::assertEquals($output, [
0 => "1901",
1 => "2000",
2 => "00",
3 => "00",
4 => "+",
5 => "",
]);
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
$output = NodaTimeSplitter::attempt_splitting("20. Jhdt.");
self::assertEquals($output, [
0 => "1901",
1 => "2000",
2 => "00",
3 => "00",
4 => "+",
5 => "",
]);
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
$output = NodaTimeSplitter::attempt_splitting("20. Jahrhundert");
self::assertEquals($output, [
0 => "1901",
1 => "2000",
2 => "00",
3 => "00",
4 => "+",
5 => "",
]);
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
$output = NodaTimeSplitter::attempt_splitting("20.-19. Jahrhundert v. Chr."); $output = NodaTimeSplitter::attempt_splitting("20.-19. Jahrhundert v. Chr.");
self::assertEquals($output, [ self::assertEquals($output, [
0 => "-2000", 0 => "-2000",