From cbe0c58644c7cbe7f09ee766e37aa9a3c2df3f06 Mon Sep 17 00:00:00 2001 From: Timon Engelke Date: Wed, 18 Dec 2024 11:16:59 +0100 Subject: [PATCH 1/2] filter: keep all-day events in TimeFrame filter --- internal/filter/timeFrame.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/filter/timeFrame.go b/internal/filter/timeFrame.go index a00699c..165fe22 100644 --- a/internal/filter/timeFrame.go +++ b/internal/filter/timeFrame.go @@ -14,6 +14,11 @@ func (a TimeFrameEvents) Name() string { } func (a TimeFrameEvents) Filter(event models.Event) bool { + // if it is an all-day event, it should not be filtered here, + // the AllDayEvents filter should be used instead + if event.AllDay { + return true + } // if start time is inside the timeframe // example: event from 10-12, timeframe is 8-18 From 30a3b97f8d7bea7b77a3e1610b9079c041dcf2d0 Mon Sep 17 00:00:00 2001 From: Timon Engelke Date: Wed, 18 Dec 2024 13:36:47 +0100 Subject: [PATCH 2/2] event: correctly handle all-day events --- internal/models/event.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/internal/models/event.go b/internal/models/event.go index 7713c2f..b916f45 100644 --- a/internal/models/event.go +++ b/internal/models/event.go @@ -133,14 +133,30 @@ func IsSameEvent(a, b Event) bool { return false } - if !a.StartTime.Equal(b.StartTime) { - log.Debugf("StartTime of Source Event %s changed, sourceTime: %s, sinkTime: %s ", a.Title, a.StartTime, b.StartTime) + if a.AllDay != b.AllDay { + log.Debugf("AllDay of Source Event %s at %s changed", a.Title, a.StartTime) return false } - if !a.EndTime.Equal(b.EndTime) { - log.Debugf("EndTime of Source Event %s changed, sourceTime: %s, sinkTime: %s ", a.Title, a.StartTime, b.StartTime) - return false + if a.AllDay && b.AllDay { + // only compare dates + if a.StartTime.Year() != b.StartTime.Year() || a.StartTime.YearDay() != b.StartTime.YearDay() { + log.Debugf("StartTime of all-day event %s changed, sourceTime: %s, sinkTime: %s", a.Title, a.StartTime.Format(time.DateOnly), b.StartTime.Format(time.DateOnly)) + return false + } + if a.EndTime.Year() != b.EndTime.Year() || a.EndTime.YearDay() != b.EndTime.YearDay() { + log.Debugf("EndTime of all-day event %s changed, sourceTime: %s, sinkTime: %s", a.Title, a.EndTime.Format(time.DateOnly), b.EndTime.Format(time.DateOnly)) + return false + } + } else { + if !a.StartTime.Equal(b.StartTime) { + log.Debugf("StartTime of Source Event %s changed, sourceTime: %s, sinkTime: %s ", a.Title, a.StartTime, b.StartTime) + return false + } + if !a.EndTime.Equal(b.EndTime) { + log.Debugf("EndTime of Source Event %s changed, sourceTime: %s, sinkTime: %s ", a.Title, a.StartTime, b.StartTime) + return false + } } if a.AllDay != b.AllDay {