Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix weekday durationToNextRun error #293

Merged
merged 2 commits into from
Feb 16, 2022
Merged

fix weekday durationToNextRun error #293

merged 2 commits into from
Feb 16, 2022

Conversation

xwjdsh
Copy link

@xwjdsh xwjdsh commented Feb 15, 2022

What does this do?

fix #282

For the following test code, the duration of the durationToNextRun is 0s, then if I change it to s.Every(1).Hour()... or s.Every(1).Day()..., the duration is 24h0m0s / 1h0m0s, I think the logic of weekday duration calculation should same as day/hour and other units, add a cycle if nextRunTime equals lastRunTime.


package main

import (
	"fmt"
	"time"

	"github.com/go-co-op/gocron"
)

func main() {
	s := gocron.NewScheduler(time.UTC)
	s.StartAsync()

	t := time.Date(2022, 1, 24, 0, 0, 0, 0, time.UTC)

	s.Every(1). Monday().StartAt(t).Do(func() {})
	fmt.Println(s.NextRun())
	fmt.Println(s.NextRun())

	ch := make(chan bool)
	<-ch
}

@JohnRoesler JohnRoesler merged commit 8a459c0 into go-co-op:main Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - panic: runtime error: integer divide by zero
2 participants