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)
| 69 | // sched, err := specParser.Parse("15 */3") |
| 70 | // |
| 71 | func 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. |
no outgoing calls