Skip to content

Commit

Permalink
Merge pull request #32 from millotp/main
Browse files Browse the repository at this point in the history
fix: 0 is forbidden for day
  • Loading branch information
adhocore authored Sep 20, 2023
2 parents f878463 + 8aee396 commit 06e7337
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ func (c *SegmentChecker) isOffsetDue(offset string, val, pos int) (bool, error)
return false, err
}

if !isWeekDay && (val == 0 || nval == 0) {
return nval == 0 && val == 0, nil
}

if nval < bounds[0] || nval > bounds[1] {
return false, fmt.Errorf("segment#%d: '%s' out of bounds(%d, %d)", pos, offset, bounds[0], bounds[1])
}

if !isWeekDay && (val == 0 || nval == 0) {
return nval == 0 && val == 0, nil
}

return nval == val || (isWeekDay && nval == 7 && val == 0), nil
}

Expand Down
1 change: 1 addition & 0 deletions gronx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func errcases() []Case {
{"1-Z * * * *", "2011-07-01 00:01:00", false, ""},
{"1-Z/2 * * * *", "2011-07-01 00:01:00", false, ""},
{"Z-Z/2 * * * *", "2011-07-01 00:01:00", false, ""},
{"* * 0 * *", "2011-07-01 00:01:00", false, ""},
{"* * * W * *", "", false, ""},
{"* * * ZW * *", "", false, ""},
{"* * * * 4W", "2011-07-01 00:00:00", false, ""},
Expand Down

0 comments on commit 06e7337

Please sign in to comment.