@@ -33,6 +33,7 @@ func (c *SegmentChecker) SetRef(ref time.Time) {
33
33
func (c * SegmentChecker ) CheckDue (segment string , pos int ) (bool , error ) {
34
34
ref := c .GetRef ()
35
35
val , loc := valueByPos (ref , pos ), ref .Location ()
36
+ last := time .Date (ref .Year (), ref .Month (), 1 , 0 , 0 , 0 , 0 , loc ).AddDate (0 , 1 , 0 ).Add (- time .Nanosecond ).Day ()
36
37
37
38
for _ , offset := range strings .Split (segment , "," ) {
38
39
mod := pos == 2 || pos == 4
@@ -45,25 +46,25 @@ func (c *SegmentChecker) CheckDue(segment string, pos int) (bool, error) {
45
46
continue
46
47
}
47
48
48
- last := time .Date (ref .Year (), ref .Month (), 1 , 0 , 0 , 0 , 0 , loc ).AddDate (0 , 1 , 0 ).Add (- time .Nanosecond ).Day ()
49
49
if pos == 2 {
50
- return isValidMonthDay (offset , last , ref )
50
+ due , err = isValidMonthDay (offset , last , ref )
51
+ } else if pos == 4 {
52
+ due , err = isValidWeekDay (offset , last , ref )
51
53
}
52
- if pos == 4 {
53
- return isValidWeekDay ( offset , last , ref )
54
+ if due || err != nil {
55
+ return due , err
54
56
}
55
57
}
56
58
57
59
return false , nil
58
60
}
59
61
60
62
func (c * SegmentChecker ) isOffsetDue (offset string , val int ) (bool , error ) {
61
- if strings .Contains (offset , "/" ) && inStep ( val , offset ) {
62
- return true , nil
63
+ if strings .Contains (offset , "/" ) {
64
+ return inStep ( val , offset )
63
65
}
64
-
65
- if strings .Contains (offset , "-" ) && inRange (val , offset ) {
66
- return true , nil
66
+ if strings .Contains (offset , "-" ) {
67
+ return inRange (val , offset )
67
68
}
68
69
69
70
if val == 0 || offset == "0" {
0 commit comments