From e07c266d8c74d7a34c049e4c700610ab771168fa Mon Sep 17 00:00:00 2001 From: bbaa Date: Fri, 22 Sep 2023 00:19:10 +0800 Subject: [PATCH] fix Scheduler.NextRun() not returning the correct value (#574) (#575) * fix Scheduler.NextRun() not returning the correct value * if the nearest run is zero we'll never be before it --------- Co-authored-by: John Roesler --- scheduler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduler.go b/scheduler.go index 926730b8..0f3657aa 100644 --- a/scheduler.go +++ b/scheduler.go @@ -522,7 +522,7 @@ func (s *Scheduler) NextRun() (*Job, time.Time) { var nearestRun time.Time for _, job := range s.jobsMap() { nr := job.NextRun() - if nr.Before(nearestRun) && s.now().Before(nr) { + if (nr.Before(nearestRun) || nearestRun.IsZero()) && s.now().Before(nr) { nearestRun = nr jobID = job.id }