Skip to content

Commit

Permalink
fix Scheduler.NextRun() not returning the correct value (#574) (#575)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
bbaa-bbaa and JohnRoesler authored Sep 21, 2023
1 parent 01fcdee commit e07c266
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e07c266

Please sign in to comment.