From a1582e38194fef918fc53b2c7e0c3c4b6aaea07c Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Mon, 9 Jan 2023 14:19:22 +0100 Subject: [PATCH] Consider today's exceptions --- model/alarm.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/alarm.go b/model/alarm.go index d2f75e3..f9cc19b 100644 --- a/model/alarm.go +++ b/model/alarm.go @@ -109,7 +109,7 @@ func DropNextAlarm(cfg *config.Config, db *LevelDBStorage) error { return PutAlarmException(db, &AlarmException{ Start: &start, End: &stop, - Comment: fmt.Sprintf("Automatic exception to cancel recurrent alarm %s", next.Format("Mon at 15:05")), + Comment: fmt.Sprintf("Automatic exception to cancel recurrent alarm %s", next.Format("Mon at 15:04")), }) } } @@ -167,11 +167,11 @@ func (a *AlarmRepeated) FillExcepts(cfg *config.Config, db *LevelDBStorage) erro now := time.Now() for _, exception := range exceptions { - if now.After(time.Time(*exception.End)) { + end := time.Time(*exception.End).AddDate(0, 0, 1) + if now.After(end) { continue } - end := time.Time(*exception.End).AddDate(0, 0, 1) for t := time.Time(*exception.Start); end.After(t); t = t.AddDate(0, 0, 1) { if t.Weekday() == a.Weekday { a.Excepts = append(a.Excepts, time.Date(t.Year(), t.Month(), t.Day(), time.Time(*a.StartTime).Hour(), time.Time(*a.StartTime).Minute(), time.Time(*a.StartTime).Second(), 0, time.Local))