Consider today's exceptions
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details

This commit is contained in:
nemunaire 2023-01-09 14:19:22 +01:00
parent 2c146f5615
commit a1582e3819
1 changed files with 3 additions and 3 deletions

View File

@ -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))