mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-09 14:07:24 -06:00
add OnlyOnDates to schedule, change exceptionday to exceptiondates everywhere
This commit is contained in:
19
listeners.go
19
listeners.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user