MCPcopy
hub / github.com/robfig/cron / NewParser

Function NewParser

parser.go:71–83  ·  view source on GitHub ↗

NewParser creates a Parser with custom options. It panics if more than one Optional is given, since it would be impossible to correctly infer which optional is provided or missing in general. Examples Standard parser without descriptors specParser := NewParser(Minute | Hour | Dom | Month | Dow) s

(options ParseOption)

Source from the content-addressed store, hash-verified

69// sched, err := specParser.Parse("15 */3")
70//
71func NewParser(options ParseOption) Parser {
72 optionals := 0
73 if options&DowOptional > 0 {
74 optionals++
75 }
76 if options&SecondOptional > 0 {
77 optionals++
78 }
79 if optionals > 1 {
80 panic("multiple optionals may not be configured")
81 }
82 return Parser{options}
83}
84
85// Parse returns a new crontab schedule representing the given spec.
86// It returns a descriptive error if the spec is not valid.

Callers 6

parser_test.goFile · 0.85
TestNoDescriptorParserFunction · 0.85
parser.goFile · 0.85
WithSecondsFunction · 0.85
TestWithParserFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestNoDescriptorParserFunction · 0.68
TestWithParserFunction · 0.68