Fix edge case 200 b.c. in NodaSplitTime

This commit is contained in:
2024-07-08 01:27:03 +02:00
parent 27528c9cf7
commit 58d3569718
4 changed files with 47 additions and 11 deletions

View File

@ -306,6 +306,23 @@ final class NodaSplitTime {
false|string $end_date = false,
) {
if (substr($start_year, 0, 1) === '-') {
if (strlen($start_year) > 5) $start_year = '-' . str_pad(trim($start_year, '-'), 4, '-', STR_PAD_LEFT);
}
if ($start_date !== false && str_starts_with($start_date, '-')) {
$parts = explode('-', trim($start_date, '-'));
$parts[0] = str_pad($parts[0], 4, '0', STR_PAD_LEFT);
$start_date = '-' . implode('-', $parts);
}
if (substr($end_year, 0, 1) === '-') {
if (strlen($end_year) > 5) $end_year = '-' . str_pad(trim($end_year, '-'), 4, '-', STR_PAD_LEFT);
}
if ($end_date !== false && str_starts_with($end_date, '-')) {
$parts = explode('-', trim($end_date, '-'));
$parts[0] = str_pad($parts[0], 4, '0', STR_PAD_LEFT);
$end_date = '-' . implode('-', $parts);
}
$this->counting_time_indicator = $counting_time_indicator;
$this->before_after_indicator = $before_after_indicator;