Skip to content

Commit

Permalink
Display next due time correctly for sub-minute events
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher committed Jul 12, 2023
1 parent a7244f4 commit 07033bd
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Illuminate/Console/Scheduling/ScheduleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,31 @@ private function sortEvents(\Illuminate\Support\Collection $events, DateTimeZone
*/
private function getNextDueDateForEvent($event, DateTimeZone $timezone)
{
return Carbon::instance(
$nextDueDate = Carbon::instance(
(new CronExpression($event->expression))
->getNextRunDate(Carbon::now()->setTimezone($event->timezone))
->setTimezone($timezone)
);

if (! $event->isRepeatable()) {
return $nextDueDate;
}

$previousDueDate = Carbon::instance(
(new CronExpression($event->expression))
->getPreviousRunDate(Carbon::now()->setTimezone($event->timezone), allowCurrentDate: true)
->setTimezone($timezone)
);

$now = Carbon::now()->setTimezone($event->timezone);

if (! $now->copy()->startOfMinute()->eq($previousDueDate)) {
return $nextDueDate;
}

return $now
->endOfSecond()
->ceilSeconds($event->repeatSeconds);
}

/**
Expand Down

0 comments on commit 07033bd

Please sign in to comment.