Reject intervals that are out of order
If an interval if out of order, it ends up emitting 0000-00-00 00:00:00 as the "next" time, which is undesirable. This patch updates Parse to simply reject such intervals. Since the rejection reason might not be super obvious (the range 6-7 is actually translated to 6-0, which makes it invalid), let's also print the original vs. normalized form for clarity. See: https://github.com/aptible/supercronic/issues/63
This commit is contained in:
@@ -438,6 +438,9 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error)
|
||||
directive.first = desc.atoi(snormal[pairs[2]:pairs[3]])
|
||||
directive.last = desc.atoi(snormal[pairs[4]:pairs[5]])
|
||||
directive.step = 1
|
||||
if directive.last < directive.first {
|
||||
return nil, fmt.Errorf("invalid interval %s (normalized to %d-%d)", snormal, directive.first, directive.last)
|
||||
}
|
||||
directives = append(directives, &directive)
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user