Fix tests

This commit is contained in:
James Cole
2024-04-21 07:07:06 +02:00
parent 6d39b8468c
commit 1a1e06e6e8

View File

@@ -464,14 +464,15 @@ class Navigation
$increment = 'addDay';
$format = $this->preferredCarbonFormat($start, $end);
$displayFormat = (string)trans('config.month_and_day_js', [], $locale);
$diff = $start->diffInMonths($end, true);
// increment by month (for year)
if ($start->diffInMonths($end, true) > 1.0) {
if ($diff >= 1.0001) {
$increment = 'addMonth';
$displayFormat = (string)trans('config.month_js');
}
// increment by year (for multi-year)
if ($start->diffInMonths($end, true) > 12.0) {
if ($diff >= 12.0001) {
$increment = 'addYear';
$displayFormat = (string)trans('config.year_js');
}
@@ -494,11 +495,15 @@ class Navigation
public function preferredCarbonFormat(Carbon $start, Carbon $end): string
{
$format = 'Y-m-d';
if ($start->diffInMonths($end, true) > 1.0) {
$diff = $start->diffInMonths($end, true);
Log::debug(sprintf('preferredCarbonFormat(%s, %s) = %f', $start->format('Y-m-d'), $end->format('Y-m-d'), $diff));
if ($diff >= 1.001) {
Log::debug(sprintf('Return Y-m because %s', $diff));
$format = 'Y-m';
}
if ($start->diffInMonths($end, true) > 12.0) {
if ($diff >= 12.001) {
Log::debug(sprintf('Return Y because %s', $diff));
$format = 'Y';
}