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

Function getFieldMaxValue

cron.go:421–444  ·  view source on GitHub ↗
(t time.Time, fieldType fieldType)

Source from the content-addressed store, hash-verified

419}
420
421func getFieldMaxValue(t time.Time, fieldType fieldType) int {
422
423 if cronFieldDayOfMonth == fieldType.Field {
424 switch int(t.Month()) {
425 case 2:
426 if isLeapYear(t.Year()) {
427 return 29
428 }
429 return 28
430 case 4:
431 return 30
432 case 6:
433 return 30
434 case 9:
435 return 30
436 case 11:
437 return 30
438 default:
439 return 31
440 }
441 }
442
443 return fieldType.MaxValue
444}
445
446func isLeapYear(year int) bool {
447 return year%400 == 0 || year%100 != 0 && year%4 == 0

Callers 2

nextFieldMethod · 0.85
elapseUntilFunction · 0.85

Calls 1

isLeapYearFunction · 0.85

Tested by

no test coverage detected