add OnlyOnDates to schedule, change exceptionday to exceptiondates everywhere

This commit is contained in:
Sam Lewis
2022-11-26 23:36:19 -05:00
parent 555bafa2e5
commit 60349852e6
6 changed files with 70 additions and 53 deletions

View File

@@ -62,7 +62,7 @@ func checkThrottle(throttle time.Duration, lastRan carbon.Carbon) conditionCheck
return cc
}
func checkExceptionDays(eList []time.Time) conditionCheck {
func checkExceptionDates(eList []time.Time) conditionCheck {
cc := conditionCheck{fail: false}
for _, e := range eList {
y1, m1, d1 := e.Date()
@@ -87,6 +87,23 @@ func checkExceptionRanges(eList []timeRange) conditionCheck {
return cc
}
func checkAllowlistDates(eList []time.Time) conditionCheck {
if len(eList) == 0 {
return conditionCheck{fail: false}
}
cc := conditionCheck{fail: true}
for _, e := range eList {
y1, m1, d1 := e.Date()
y2, m2, d2 := time.Now().Date()
if y1 == y2 && m1 == m2 && d1 == d2 {
cc.fail = false
break
}
}
return cc
}
func checkStartEndTime(s TimeString, isStart bool) conditionCheck {
cc := conditionCheck{fail: false}
// pass immediately if default