From 34d8e2dafbf2274ee7e2a59ed21e7e05f65e4685 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 17 Dec 2017 22:26:40 -0500 Subject: [PATCH] More algowhizbang that now almost matches manual calc --- wherewhen/cmd/wherewhen/main.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/wherewhen/cmd/wherewhen/main.go b/wherewhen/cmd/wherewhen/main.go index e9a2e66..afb64cc 100644 --- a/wherewhen/cmd/wherewhen/main.go +++ b/wherewhen/cmd/wherewhen/main.go @@ -137,7 +137,7 @@ func main() { evt.Location = loc if evt.Start == evt.End { - log.Printf("skipping same-day event on %s", evt.Start) + log.Printf("skipping same-day event on %s (%s)", evt.Start, evt.Summary) continue } foundEvents = append(foundEvents, evt) @@ -151,6 +151,7 @@ func main() { for _, evt := range foundEvents { log.Printf("checking if %s is in range %s %s", day.Date, evt.Start, evt.End) if evt.HasDate(day.Date) { + log.Printf("match found for %s in range %s %s, setting location to %s", day.Date, evt.Start, evt.End, evt.Location) day.Location = evt.Location } } @@ -236,8 +237,8 @@ type lilEvent struct { } func (e *lilEvent) HasDate(d string) bool { - if e.Start == d || e.End == d { - log.Printf("match for %s in %s or %s", d, e.Start, e.End) + if e.Start == d { + log.Printf("match for %s at %s", d, e.Start) return true } @@ -273,12 +274,7 @@ type lilDay struct { func generateDays(startT, endT time.Time) []*lilDay { defaultLocation := *defaultLocationFlag - days := []*lilDay{ - { - Date: startT.Format(dateFmt), - Location: defaultLocation, - }, - } + days := []*lilDay{} curT := startT for {