diff --git a/src/NodaTimeAutotranslater.php b/src/NodaTimeAutotranslater.php index e65993f..3f7a9b3 100644 --- a/src/NodaTimeAutotranslater.php +++ b/src/NodaTimeAutotranslater.php @@ -338,7 +338,7 @@ final class NodaTimeAutotranslater { return self::TRANSLATABLE_CENTURY; } - if ((intval($zeit_ende) + 1) % 10 === 0 and intval($zeit_beginn) % 10 === 0) { + if ((intval($zeit_ende) + 1) % 10 === 0 and intval($zeit_beginn) % 10 === 0 and intval($zeit_beginn) > 1000) { return self::TRANSLATABLE_DECADE; } diff --git a/tests/NodaTimeAutotranslaterTest.php b/tests/NodaTimeAutotranslaterTest.php index 11e02ce..cdd1247 100644 --- a/tests/NodaTimeAutotranslaterTest.php +++ b/tests/NodaTimeAutotranslaterTest.php @@ -101,6 +101,28 @@ final class NodaTimeAutotranslaterTest extends TestCase { } + /** + * Test to check whether the HTML page is correctly generated. + * + * @author Joshua Ramon Enslin + * @group ValidOutput + * + * @return void + */ + public function testCanTranslateDecade():void { + + $timeInfo = [ + "zeit_beginn" => "1920", + "zeit_ende" => "1929", + "zeit_zaehlzeit_jahr" => "1925", + "zeit_zaehlzeit_monat" => "00", + "zeit_zaehlzeit_tag" => "00", + ]; + $output = NodaTimeAutotranslater::getTranslations($timeInfo); + self::assertEquals($output["de"], "1920er Jahre"); + + } + /** * Test to check whether the HTML page is correctly generated. * @@ -123,6 +145,28 @@ final class NodaTimeAutotranslaterTest extends TestCase { } + /** + * Test to check whether the HTML page is correctly generated. + * + * @author Joshua Ramon Enslin + * @group ValidOutput + * + * @return void + */ + public function testTranslateDecadeBeforeCommonEraAsTimespan():void { + + $timeInfo = [ + "zeit_beginn" => "-10", + "zeit_ende" => "-1", + "zeit_zaehlzeit_jahr" => "0005", + "zeit_zaehlzeit_monat" => "00", + "zeit_zaehlzeit_tag" => "00", + ]; + $output = NodaTimeAutotranslater::getTranslations($timeInfo); + self::assertEquals($output["de"], "10-1 v. Chr."); + + } + /** * Test to check whether the HTML page is correctly generated. *