parent
f84fe1bca5
commit
dba60dbce6
@ -345,6 +345,10 @@ final class NodaTimeSplitter {
|
||||
$start_date = $output->start_date;
|
||||
$end_date = $output->end_date;
|
||||
}
|
||||
else if ($start === $end && (int)str_replace('-', '', $start_date) > (int)str_replace('-', '', $end_date)) {
|
||||
$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, '-' . $start_date, '-' . $end_date);
|
||||
}
|
||||
@ -752,7 +756,7 @@ final class NodaTimeSplitter {
|
||||
return new NodaSplitTime($year, $year);
|
||||
}
|
||||
|
||||
if (str_starts_with($inpDateWoSpaces, '0-') || str_ends_with($inpDateWoSpaces, '-0') && \preg_match("/^[0-9]{4}$/", \strtr($inpDateWoSpaces, ['-0' => '', '0-' => '']))) {
|
||||
if ((str_starts_with($inpDateWoSpaces, '0-') || str_ends_with($inpDateWoSpaces, '-0')) && \preg_match("/^[0-9]{4}$/", \strtr($inpDateWoSpaces, ['-0' => '', '0-' => ''])) && !str_ends_with($inpDateWoSpaces, '0-0')) {
|
||||
$year = \strtr($inpDateWoSpaces, ['-0' => '', '0-' => '']);
|
||||
if (strlen($year) === 4) {
|
||||
return new NodaSplitTime($year, $year);
|
||||
|
@ -166,6 +166,14 @@ final class NodaTimeSplitterTest extends TestCase {
|
||||
end_date: '2017-12-31'),
|
||||
"1930-2017",
|
||||
],
|
||||
"18 v. Chr." => [
|
||||
"18 v. Chr.",
|
||||
new NodaSplitTime('-18', '-18',
|
||||
counting_time_indicator: NodaCountingTimeIndicator::bce,
|
||||
start_date: '-0018-01-01',
|
||||
end_date: '-0018-12-31'),
|
||||
"18 v. Chr.",
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
@ -182,8 +190,8 @@ final class NodaTimeSplitterTest extends TestCase {
|
||||
"1925 BCE",
|
||||
new NodaSplitTime('-1925', '-1925',
|
||||
counting_time_indicator: NodaCountingTimeIndicator::bce,
|
||||
start_date: '-1925-12-31',
|
||||
end_date: '-1925-01-01'),
|
||||
start_date: '-1925-01-01',
|
||||
end_date: '-1925-12-31'),
|
||||
"1925 v. Chr.",
|
||||
],
|
||||
"1925 CE" => [
|
||||
@ -668,18 +676,18 @@ final class NodaTimeSplitterTest extends TestCase {
|
||||
self::assertEquals($output->toTimeName(), "2020");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("2020-0");
|
||||
$output = NodaTimeSplitter::attempt_splitting("2021-0");
|
||||
self::assertNotEmpty($output);
|
||||
self::assertEquals($output->toOldFormat(), [
|
||||
0 => "2020",
|
||||
1 => "2020",
|
||||
0 => "2021",
|
||||
1 => "2021",
|
||||
2 => "00",
|
||||
3 => "00",
|
||||
4 => "+",
|
||||
5 => "",
|
||||
]);
|
||||
self::assertEquals($output->toTimeName(), "2020");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
||||
self::assertEquals("2021", $output->toTimeName());
|
||||
self::assertEquals(2021, NodaTimeSplitter::timePartsToCountingYear($output));
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("1920-1929");
|
||||
self::assertNotEmpty($output);
|
||||
|
Loading…
x
Reference in New Issue
Block a user