Allow automatic translations of days before 1000 CE
This commit is contained in:
@ -35,6 +35,50 @@ final class NodaTimeAutotranslaterTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to check whether the HTML page is correctly generated.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
* @group ValidOutput
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCanTranslateSingleDayWith2DigitYear():void {
|
||||
|
||||
$timeInfo = [
|
||||
"zeit_beginn" => "20",
|
||||
"zeit_ende" => "20",
|
||||
"zeit_zaehlzeit_jahr" => "0020",
|
||||
"zeit_zaehlzeit_monat" => "05",
|
||||
"zeit_zaehlzeit_tag" => "01",
|
||||
];
|
||||
$output = NodaTimeAutotranslater::getTranslations($timeInfo);
|
||||
self::assertEquals($output["de"], "01.05.20");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to check whether the HTML page is correctly generated.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
* @group ValidOutput
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCanTranslateSingleDayWith2DigitYearBeforeCommonEra():void {
|
||||
|
||||
$timeInfo = [
|
||||
"zeit_beginn" => "-20",
|
||||
"zeit_ende" => "-20",
|
||||
"zeit_zaehlzeit_jahr" => "0020",
|
||||
"zeit_zaehlzeit_monat" => "05",
|
||||
"zeit_zaehlzeit_tag" => "01",
|
||||
];
|
||||
$output = NodaTimeAutotranslater::getTranslations($timeInfo);
|
||||
self::assertEquals($output["de"], "01.05.20 v. Chr.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to check whether the HTML page is correctly generated.
|
||||
*
|
||||
@ -167,6 +211,28 @@ final class NodaTimeAutotranslaterTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to check whether the HTML page is correctly generated.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
* @group ValidOutput
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTranslateDecadeBeforeCommonEraAsTimespan4Digits():void {
|
||||
|
||||
$timeInfo = [
|
||||
"zeit_beginn" => "-1910",
|
||||
"zeit_ende" => "-1901",
|
||||
"zeit_zaehlzeit_jahr" => "0005",
|
||||
"zeit_zaehlzeit_monat" => "00",
|
||||
"zeit_zaehlzeit_tag" => "00",
|
||||
];
|
||||
$output = NodaTimeAutotranslater::getTranslations($timeInfo);
|
||||
self::assertEquals($output["de"], "1910-1901 v. Chr.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to check whether the HTML page is correctly generated.
|
||||
*
|
||||
|
@ -24,6 +24,54 @@ final class NodaTimeSplitterTest extends TestCase {
|
||||
*/
|
||||
public function testSplitSimpleDatesGerman():void {
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("02.1.25 v. Chr");
|
||||
self::assertEquals($output, [
|
||||
0 => "-25",
|
||||
1 => "-25",
|
||||
2 => "01",
|
||||
3 => "02",
|
||||
4 => "-",
|
||||
5 => "",
|
||||
]);
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.25 v. Chr.");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("2.01.25 v. Chr");
|
||||
self::assertEquals($output, [
|
||||
0 => "-25",
|
||||
1 => "-25",
|
||||
2 => "01",
|
||||
3 => "02",
|
||||
4 => "-",
|
||||
5 => "",
|
||||
]);
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.25 v. Chr.");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("02.01.25 v. Chr");
|
||||
self::assertEquals($output, [
|
||||
0 => "-25",
|
||||
1 => "-25",
|
||||
2 => "01",
|
||||
3 => "02",
|
||||
4 => "-",
|
||||
5 => "",
|
||||
]);
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.25 v. Chr.");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("2.1.25 v. Chr");
|
||||
self::assertEquals($output, [
|
||||
0 => "-25",
|
||||
1 => "-25",
|
||||
2 => "01",
|
||||
3 => "02",
|
||||
4 => "-",
|
||||
5 => "",
|
||||
]);
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.25 v. Chr.");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("2.1.2020");
|
||||
self::assertEquals($output, [
|
||||
0 => "2020",
|
||||
|
Reference in New Issue
Block a user