Skip to content

Commit e9814be

Browse files
committed
zep: correctly identify all-day events
1 parent 50d1233 commit e9814be

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

internal/adapter/zep/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func (zep *CalendarAPI) EventsInTimeframe(ctx context.Context, start time.Time,
112112
Description: v.Description,
113113
StartTime: v.Start,
114114
EndTime: v.End,
115+
AllDay: isAllDayEvent(v),
115116
Accepted: true,
116117
Metadata: models.NewEventMetadata(v.ID, "", zep.GetCalendarHash()),
117118
})

internal/adapter/zep/event.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
const (
9-
DateFormat = "02.01.2006"
9+
DateFormat = "02.01.2006 15:04"
1010
)
1111

1212
// Event is a simplified representation for an event which has been entered in ZEP.
@@ -23,3 +23,15 @@ type Event struct {
2323
func (a Event) String() string {
2424
return fmt.Sprintf("%s | %s | %s | %s | %s | %s", a.ID, a.Start.Format(DateFormat), a.End.Format(DateFormat), a.Category, a.Summary, a.Description)
2525
}
26+
27+
func isAllDayEvent(event Event) bool {
28+
h, m, s := event.Start.Clock()
29+
if h != 0 || m != 0 || s != 0 {
30+
return false
31+
}
32+
h, m, s = event.End.Clock()
33+
if h != 0 || m != 0 || s != 0 {
34+
return false
35+
}
36+
return true
37+
}

0 commit comments

Comments
 (0)