cron
cron copied to clipboard
what is the starbit used for?
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
}
It seems starBit means <asterisk>
https://github.com/robfig/cron/issues/70#issuecomment-246892837
- https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html
- https://pubs.opengroup.org/onlinepubs/007904975/utilities/crontab.html