This commit is contained in:
James Cole
2020-07-26 07:57:48 +02:00
parent 4b16d7c53d
commit 83467ef2f2
10 changed files with 112 additions and 56 deletions

View File

@@ -46,11 +46,11 @@ trait CalculateRangeOccurrences
{
$return = [];
$attempts = 0;
Log::debug('Rep is daily. Start of loop.');
#Log::debug('Rep is daily. Start of loop.');
while ($start <= $end) {
Log::debug(sprintf('Mutator is now: %s', $start->format('Y-m-d')));
#Log::debug(sprintf('Mutator is now: %s', $start->format('Y-m-d')));
if (0 === $attempts % $skipMod) {
Log::debug(sprintf('Attempts modulo skipmod is zero, include %s', $start->format('Y-m-d')));
#Log::debug(sprintf('Attempts modulo skipmod is zero, include %s', $start->format('Y-m-d')));
$return[] = clone $start;
}
$start->addDay();
@@ -77,27 +77,27 @@ trait CalculateRangeOccurrences
$return = [];
$attempts = 0;
$dayOfMonth = (int)$moment;
Log::debug(sprintf('Day of month in repetition is %d', $dayOfMonth));
Log::debug(sprintf('Start is %s.', $start->format('Y-m-d')));
Log::debug(sprintf('End is %s.', $end->format('Y-m-d')));
#Log::debug(sprintf('Day of month in repetition is %d', $dayOfMonth));
#Log::debug(sprintf('Start is %s.', $start->format('Y-m-d')));
#Log::debug(sprintf('End is %s.', $end->format('Y-m-d')));
if ($start->day > $dayOfMonth) {
Log::debug('Add a month.');
#Log::debug('Add a month.');
// day has passed already, add a month.
$start->addMonth();
}
Log::debug(sprintf('Start is now %s.', $start->format('Y-m-d')));
Log::debug('Start loop.');
#Log::debug(sprintf('Start is now %s.', $start->format('Y-m-d')));
#Log::debug('Start loop.');
while ($start < $end) {
Log::debug(sprintf('Mutator is now %s.', $start->format('Y-m-d')));
#Log::debug(sprintf('Mutator is now %s.', $start->format('Y-m-d')));
$domCorrected = min($dayOfMonth, $start->daysInMonth);
Log::debug(sprintf('DoM corrected is %d', $domCorrected));
#Log::debug(sprintf('DoM corrected is %d', $domCorrected));
$start->day = $domCorrected;
Log::debug(sprintf('Mutator is now %s.', $start->format('Y-m-d')));
Log::debug(sprintf('$attempts %% $skipMod === 0 is %s', var_export(0 === $attempts % $skipMod, true)));
Log::debug(sprintf('$start->lte($mutator) is %s', var_export($start->lte($start), true)));
Log::debug(sprintf('$end->gte($mutator) is %s', var_export($end->gte($start), true)));
#Log::debug(sprintf('Mutator is now %s.', $start->format('Y-m-d')));
#Log::debug(sprintf('$attempts %% $skipMod === 0 is %s', var_export(0 === $attempts % $skipMod, true)));
#Log::debug(sprintf('$start->lte($mutator) is %s', var_export($start->lte($start), true)));
#Log::debug(sprintf('$end->gte($mutator) is %s', var_export($end->gte($start), true)));
if (0 === $attempts % $skipMod && $start->lte($start) && $end->gte($start)) {
Log::debug(sprintf('ADD %s to return!', $start->format('Y-m-d')));
#Log::debug(sprintf('ADD %s to return!', $start->format('Y-m-d')));
$return[] = clone $start;
}
$attempts++;