Time splitter: Handle first/second half

Close #31
This commit is contained in:
Joshua Ramon Enslin 2025-04-05 00:09:39 +02:00
parent 8491b62a83
commit e8edb4a459
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
3 changed files with 25 additions and 2 deletions

View File

@ -1101,6 +1101,15 @@ final class NodaTimeSplitter {
if (empty($datum)) return ''; if (empty($datum)) return '';
if (\preg_match("/^1\.\ (Halbjahr|Hälfte)\ [0-9]{4}$/", $datum)) {
$year = substr($datum, -4);
return "Januar $year-Juni $year";
}
if (\preg_match("/^2\.\ (Halbjahr|Hälfte)\ [0-9]{4}$/", $datum)) {
$year = substr($datum, -4);
return "Juli $year-Dezember $year";
}
$inputLength = strlen($datum); $inputLength = strlen($datum);
// Hungarian year and month until month // Hungarian year and month until month

View File

@ -6,12 +6,14 @@
*/ */
declare(strict_types = 1); declare(strict_types = 1);
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
/** /**
* This script contains tests for the actor name splitter. * This script contains tests for the actor name splitter.
*
* @covers \NodaNameSplitter
*/ */
#[Small]
#[CoversClass(\NodaIDGetter::class)]
final class NodaNameSplitterTest extends TestCase { final class NodaNameSplitterTest extends TestCase {
/** /**
* Test to check whether the HTML page is correctly generated. * Test to check whether the HTML page is correctly generated.

View File

@ -509,6 +509,18 @@ final class NodaTimeSplitterTest extends TestCase {
"counting_time_day" => "01", "counting_time_day" => "01",
"counting_time_bcce" => "+", "counting_time_bcce" => "+",
], ],
"1. Halbjahr 1950" => [
'start_name' => "Januar 1950",
'end_name' => "Juni 1950",
"start_year" => '1950',
"end_year" => '1950',
'start_date' => '1950-01-01',
'end_date' => '1950-06-31',
"counting_time_year" => "1950",
"counting_time_month" => "04",
"counting_time_day" => "02",
"counting_time_bcce" => "+",
],
] as $in => $out) { ] as $in => $out) {
$output[$in] = [$in, $out]; $output[$in] = [$in, $out];
} }