From ea722e20233d53c920d45924f50bf385a4a8a4a6 Mon Sep 17 00:00:00 2001 From: Craig Williams Date: Thu, 28 Apr 2022 16:04:17 +0100 Subject: [PATCH] Display the next run time of tasks --- src/Bakery/ScheduleListCommand.php | 2 +- src/Scheduler/BaseTask.php | 2 +- src/Scheduler/Scheduler.php | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Bakery/ScheduleListCommand.php b/src/Bakery/ScheduleListCommand.php index 8616521..a1917a6 100644 --- a/src/Bakery/ScheduleListCommand.php +++ b/src/Bakery/ScheduleListCommand.php @@ -42,7 +42,7 @@ class ScheduleListCommand extends BaseCommand unset($task['instance']); return $task; }, $tasks); - $this->io->table(['Schedule', 'Sprinkle', 'Name', 'Namespace'], $tasks); + $this->io->table(['Schedule', 'Sprinkle', 'Name', 'Namespace', 'Next Run'], $tasks); return self::SUCCESS; } diff --git a/src/Scheduler/BaseTask.php b/src/Scheduler/BaseTask.php index 9528d82..7a29746 100644 --- a/src/Scheduler/BaseTask.php +++ b/src/Scheduler/BaseTask.php @@ -95,7 +95,7 @@ abstract class BaseTask implements TaskInterface */ public function nextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { - return Date::instance((new CronExpression($this->getExpression())) + return Date::instance((new CronExpression($this->expression)) ->getNextRunDate($currentTime, $nth, $allowCurrentDate, $this->timezone)); } diff --git a/src/Scheduler/Scheduler.php b/src/Scheduler/Scheduler.php index b16af55..443b07f 100644 --- a/src/Scheduler/Scheduler.php +++ b/src/Scheduler/Scheduler.php @@ -203,6 +203,8 @@ class Scheduler $schedule = $taskClass->cronExpression(); + $nextRun = $taskClass->nextRunDate(); + // Build the class name and namespace return [ 'schedule' => $schedule, @@ -210,6 +212,7 @@ class Scheduler 'name' => $name, 'class' => $classPath, 'instance' => $taskClass, + 'next_run' => $nextRun, ]; } }