INNER CODE UNIT · Go
nextWeekday
asobti/kube-monkey · internal/pkg/calendar/calendar.go:29
func nextWeekday(loc *time.Location) time.Time {
check := time.Now().In(loc)
for {
check = check.AddDate(0, 0, 1)
if isWeekday(check) {
return check
}
}
}
// NextRuntime calculates the next time the Scheduled should run
func NextRuntime(loc *time.Location, r int) time.Time {
now := time.Now().In(loc)
// Is today a weekday and are we still in time for it?
if isWeekday(now) {
runtimeToday := time.Date(now.Year(), now.Month(), now.Day(), r, 0, 0, 0, loc)
if runtimeToday.After(now) {