Fix 'All-Day' tomorrow bug

This commit is contained in:
Brian Buller 2018-03-14 08:43:22 -05:00
parent 7800febdc5
commit 25f37688bb
1 changed files with 20 additions and 0 deletions

View File

@ -78,6 +78,26 @@ func (c *Calendar) GetTodaysEvents() []Event {
return ret
}
for _, e := range events.Items {
// Check if this event is an all-day event and, if so, is it actually today?
if _, err := time.Parse(time.RFC3339, e.Start.DateTime); err != nil {
tz := time.Now().Local().Format("-07:00")
stDt := e.Start.Date + "T00:00:00" + tz
stTm, err := time.Parse(time.RFC3339, stDt)
if err != nil {
continue
}
endDt := e.End.Date + "T00:00:00" + tz
endTm, err := time.Parse(time.RFC3339, endDt)
if err != nil {
continue
}
if stTm.After(maxTime) {
continue
}
if stTm.After(maxTime) || endTm.Before(minTime) {
continue
}
}
ret = append(ret, *GoogleEventToLocalWithId(e, c.Id))
}
return ret