(hasWeekdaysSuffix bool)
| 139 | } |
| 140 | |
| 141 | func (p *ScheduleParser) parseShortDurationInterval(hasWeekdaysSuffix bool) (string, bool, error) { |
| 142 | if !p.usesShortDurationSyntax(hasWeekdaysSuffix) { |
| 143 | return "", false, nil |
| 144 | } |
| 145 | |
| 146 | matches := durationPattern.FindStringSubmatch(p.tokens[1]) |
| 147 | if matches == nil { |
| 148 | return "", false, nil |
| 149 | } |
| 150 | |
| 151 | interval, err := strconv.Atoi(matches[1]) |
| 152 | if err != nil { |
| 153 | return "", true, fmt.Errorf("invalid duration interval %q: %w", matches[1], err) |
| 154 | } |
| 155 | unit := matches[2] |
| 156 | if err := p.validateIntervalTimeClause(2, hasWeekdaysSuffix); err != nil { |
| 157 | return "", true, err |
| 158 | } |
| 159 | if err := validateMinimumInterval(interval, unit); err != nil { |
| 160 | return "", true, err |
| 161 | } |
| 162 | |
| 163 | cronExpr, err := formatShortDurationCron(interval, unit, hasWeekdaysSuffix) |
| 164 | return cronExpr, true, err |
| 165 | } |
| 166 | |
| 167 | func (p *ScheduleParser) usesShortDurationSyntax(hasWeekdaysSuffix bool) bool { |
| 168 | return len(p.tokens) == 2 || |
no test coverage detected