mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 20:38:57 +00:00
Lots of code cleanup.
This commit is contained in:
@@ -83,6 +83,7 @@ class Date
|
||||
$currentEnd->addYear()->subDay();
|
||||
break;
|
||||
}
|
||||
return $currentEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,4 +125,43 @@ class Date
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param $repeatFreq
|
||||
* @param int $substract
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function substractPeriod(Carbon $date, $repeatFreq, $substract = 1)
|
||||
{
|
||||
switch ($repeatFreq) {
|
||||
default:
|
||||
throw new FireflyException('Cannot do addPeriod for $repeat_freq ' . $repeatFreq);
|
||||
break;
|
||||
case 'daily':
|
||||
$date->subDays($substract);
|
||||
break;
|
||||
case 'weekly':
|
||||
$date->subWeeks($substract);
|
||||
break;
|
||||
case 'monthly':
|
||||
$date->subMonths($substract);
|
||||
break;
|
||||
case 'quarterly':
|
||||
$months = $substract * 3;
|
||||
$date->subMonths($months);
|
||||
break;
|
||||
case 'half-year':
|
||||
$months = $substract * 6;
|
||||
$date->subMonths($months);
|
||||
break;
|
||||
case 'yearly':
|
||||
$date->subYears($substract);
|
||||
break;
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user