mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 07:38:29 +00:00
Small code quality improvements.
This commit is contained in:
@@ -33,6 +33,30 @@ use Log;
|
||||
*/
|
||||
trait DateCalculation
|
||||
{
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function calculateStep(Carbon $start, Carbon $end): string
|
||||
{
|
||||
|
||||
$step = '1D';
|
||||
$months = $start->diffInMonths($end);
|
||||
if ($months > 3) {
|
||||
$step = '1W'; // @codeCoverageIgnore
|
||||
}
|
||||
if ($months > 24) {
|
||||
$step = '1M'; // @codeCoverageIgnore
|
||||
}
|
||||
if ($months > 100) {
|
||||
$step = '1Y'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return $step;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of days between the two given dates.
|
||||
* - If today is within the two dates, give the number of days between today and the end date.
|
||||
@@ -111,7 +135,7 @@ trait DateCalculation
|
||||
while ($count < 12) {
|
||||
$format = $current->format('Y-m-d');
|
||||
$loop[$format] = app('navigation')->periodShow($current, $range);
|
||||
$current = app('navigation')->endOfPeriod($current, $range);
|
||||
$current = app('navigation')->endOfPeriod($current, $range);
|
||||
++$count;
|
||||
$current->addDay();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user