Consider today's exceptions
This commit is contained in:
parent
2c146f5615
commit
a1582e3819
@ -109,7 +109,7 @@ func DropNextAlarm(cfg *config.Config, db *LevelDBStorage) error {
|
|||||||
return PutAlarmException(db, &AlarmException{
|
return PutAlarmException(db, &AlarmException{
|
||||||
Start: &start,
|
Start: &start,
|
||||||
End: &stop,
|
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()
|
now := time.Now()
|
||||||
|
|
||||||
for _, exception := range exceptions {
|
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
|
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) {
|
for t := time.Time(*exception.Start); end.After(t); t = t.AddDate(0, 0, 1) {
|
||||||
if t.Weekday() == a.Weekday {
|
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))
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user