split daily schedule and interval

This commit is contained in:
Sam Lewis
2022-11-13 20:17:00 -05:00
parent 83998b5e7e
commit ced79559e5
7 changed files with 275 additions and 136 deletions

View File

@@ -4,6 +4,7 @@ import (
"time"
"github.com/golang-module/carbon"
"github.com/saml-dev/gome-assistant/internal"
i "github.com/saml-dev/gome-assistant/internal"
)
@@ -85,3 +86,24 @@ func checkExceptionRanges(eList []timeRange) conditionCheck {
}
return cc
}
func checkStartEndTime(s TimeString, isStart bool) conditionCheck {
cc := conditionCheck{fail: false}
// pass immediately if default
if s == "00:00" {
return cc
}
now := time.Now()
parsedTime := internal.ParseTime(string(s)).Carbon2Time()
if isStart {
if parsedTime.After(now) {
cc.fail = true
}
} else {
if parsedTime.Before(now) {
cc.fail = true
}
}
return cc
}