Fix broken time splitting for year ranges BC
This commit is contained in:
parent
eb14615917
commit
7d303e219f
|
@ -330,6 +330,7 @@ final class NodaSplitTime {
|
|||
$this->end_date = '9999-12-31';
|
||||
}
|
||||
|
||||
|
||||
if (!isset($this->start_date) && false !== $start_date) {
|
||||
$this->start_date = date("Y-m-d", MD_STD::strtotime($start_date));
|
||||
}
|
||||
|
|
|
@ -336,13 +336,17 @@ final class NodaTimeSplitter {
|
|||
|
||||
$start = \strval(-1 * \intval($output->end_year));
|
||||
$end = \strval(-1 * \intval($output->start_year));
|
||||
$start_date = $output->end_date;
|
||||
$end_date = $output->start_date;
|
||||
if (\intval($start) > \intval($end)) {
|
||||
$startToSet = $end;
|
||||
$end = $start;
|
||||
$start = $startToSet;
|
||||
$start_date = $output->start_date;
|
||||
$end_date = $output->end_date;
|
||||
}
|
||||
return new NodaSplitTime($start, $end, $output->counting_time_month, $output->counting_time_day,
|
||||
NodaCountingTimeIndicator::bce, $output->before_after_indicator, '-' . $output->end_date, '-' . $output->start_date);
|
||||
NodaCountingTimeIndicator::bce, $output->before_after_indicator, '-' . $start_date, '-' . $end_date);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -928,6 +928,8 @@ final class NodaTimeSplitterTest extends TestCase {
|
|||
'end_name' => "Februar 2004",
|
||||
"start_year" => '2004',
|
||||
"end_year" => '2004',
|
||||
'start_date' => '2004-01-01',
|
||||
'end_date' => '2004-02-31',
|
||||
"counting_time_year" => "2004",
|
||||
"counting_time_month" => "02",
|
||||
"counting_time_day" => "01",
|
||||
|
@ -942,6 +944,8 @@ final class NodaTimeSplitterTest extends TestCase {
|
|||
'end_name' => "Februar 2004",
|
||||
"start_year" => '2004',
|
||||
"end_year" => '2004',
|
||||
'start_date' => '2004-01-01',
|
||||
'end_date' => '2004-02-31',
|
||||
"counting_time_year" => "2004",
|
||||
"counting_time_month" => "02",
|
||||
"counting_time_day" => "01",
|
||||
|
@ -963,6 +967,8 @@ final class NodaTimeSplitterTest extends TestCase {
|
|||
'end_name' => "15.04.2019",
|
||||
"start_year" => '2019',
|
||||
"end_year" => '2019',
|
||||
'start_date' => '2019-03-14',
|
||||
'end_date' => '2019-04-15',
|
||||
"counting_time_year" => "2019",
|
||||
"counting_time_month" => "03",
|
||||
"counting_time_day" => "30",
|
||||
|
@ -976,6 +982,8 @@ final class NodaTimeSplitterTest extends TestCase {
|
|||
'end_name' => "15.03.2019",
|
||||
"start_year" => '2019',
|
||||
"end_year" => '2019',
|
||||
'start_date' => '2019-03-14',
|
||||
'end_date' => '2019-03-15',
|
||||
"counting_time_year" => "2019",
|
||||
"counting_time_month" => "03",
|
||||
"counting_time_day" => "15",
|
||||
|
@ -990,6 +998,8 @@ final class NodaTimeSplitterTest extends TestCase {
|
|||
'end_name' => "1900",
|
||||
"start_year" => '1601',
|
||||
"end_year" => '1900',
|
||||
'start_date' => '1601-01-01',
|
||||
'end_date' => '1900-12-31',
|
||||
"counting_time_year" => "1751",
|
||||
"counting_time_month" => "01",
|
||||
"counting_time_day" => "01",
|
||||
|
@ -1004,12 +1014,19 @@ final class NodaTimeSplitterTest extends TestCase {
|
|||
'end_name' => "1969",
|
||||
"start_year" => '1950',
|
||||
"end_year" => '1969',
|
||||
'start_date' => '1950-01-01',
|
||||
'end_date' => '1969-12-31',
|
||||
"counting_time_year" => "1960",
|
||||
"counting_time_month" => "01",
|
||||
"counting_time_day" => "01",
|
||||
"counting_time_bcce" => "+",
|
||||
]);
|
||||
|
||||
// Rewritten / 1950-60-as évek
|
||||
$output = NodaTimeSplitter::attempt_splitting("1400-1100 v. Chr.");
|
||||
self::assertEquals('-1400', $output->start_year);
|
||||
self::assertEquals('-1400-01-01', $output->start_date);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user