MCPcopy Create free account
hub / github.com/codnect/chrono / parseRange

Function parseRange

cron.go:259–296  ·  view source on GitHub ↗
(value string, fieldType fieldType)

Source from the content-addressed store, hash-verified

257}
258
259func parseRange(value string, fieldType fieldType) (valueRange, error) {
260 if value == "*" {
261 return newValueRange(fieldType.MinValue, fieldType.MaxValue), nil
262 } else {
263 hyphenPos := strings.Index(value, "-")
264
265 if hyphenPos == -1 {
266 result, err := checkValidValue(value, fieldType)
267
268 if err != nil {
269 return valueRange{}, err
270 }
271
272 return newValueRange(result, result), nil
273 } else {
274 maxStr := value[hyphenPos+1:]
275 minStr := value[0:hyphenPos]
276
277 min, err := checkValidValue(minStr, fieldType)
278
279 if err != nil {
280 return valueRange{}, err
281 }
282 var max int
283 max, err = checkValidValue(maxStr, fieldType)
284
285 if err != nil {
286 return valueRange{}, err
287 }
288
289 if fieldType.Field == cronFieldDayOfWeek && min == 7 {
290 min = 0
291 }
292
293 return newValueRange(min, max), nil
294 }
295 }
296}
297
298func replaceOrdinals(value string, list []string) string {
299 value = strings.ToUpper(value)

Callers 1

parseFieldFunction · 0.85

Calls 2

newValueRangeFunction · 0.85
checkValidValueFunction · 0.85

Tested by

no test coverage detected