Skip to content

what is the starbit used for? #471

Open

Description

@rickywei

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions