8000 what is the starbit used for? · Issue #471 · robfig/cron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

what is the starbit used for? #471

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

Open
rickywei opened this issue Nov 24, 2022 · 1 comment
Open

what is the starbit used for? #471

rickywei opened this issue Nov 24, 2022 · 1 comment

Comments

@rickywei
Copy link

First of all, thans for your great cron job.
I read dayMatches code in spec.go but did not figure out why you check starBit before return result.
Why use || operation when both starBit of dom and dow is 0. I think we always need use && to get result.
Could youhelp to explain some details of this?
Thanks in advance :)

// dayMatches returns true if the schedule's day-of-week and day-of-month
// restrictions are satisfied by the given time.
func dayMatches(s *SpecSchedule, t time.Time) bool {
	var (
		domMatch bool = 1<<uint(t.Day())&s.Dom > 0
		dowMatch bool = 1<<uint(t.Weekday())&s.Dow > 0
	)
	if s.Dom&starBit > 0 || s.Dow&starBit > 0 {
		return domMatch && dowMatch
	}
	return domMatch || dowMatch
}
@rickywei rickywei changed the title what isthe starbit used for? what is the starbit used for? Nov 25, 2022
@xuyang2
Copy link
xuyang2 commented Sep 21, 2023

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

No branches or pull requests

2 participants
0