# HG changeset patch # User Sascha L. Teichmann # Date 1556531900 -7200 # Node ID 3dffeb6df4a31aa1a78ab6efea8e7ab17c52b809 # Parent adca192a4070136d03fcb7d4f7be47500e9127cb Display Available Fairway Depths: Implemented monthly, quarterly and yearly stepping through the measurements. diff -r adca192a4070 -r 3dffeb6df4a3 pkg/controllers/bottlenecks.go --- a/pkg/controllers/bottlenecks.go Mon Apr 29 11:50:50 2019 +0200 +++ b/pkg/controllers/bottlenecks.go Mon Apr 29 11:58:20 2019 +0200 @@ -684,22 +684,40 @@ } func monthly(from, to time.Time) func() (time.Time, time.Time, string) { + pfrom := from return func() (time.Time, time.Time, string) { - // TODO: Implement me! - return time.Time{}, time.Time{}, "" + if pfrom.After(to) { + return time.Time{}, time.Time{}, "" + } + f := pfrom + pfrom = pfrom.AddDate(0, 1, 0) + label := fmt.Sprint("%02d-%d", f.Month(), f.Year()) + return f, f.AddDate(0, 1, 0).Add(-time.Nanosecond), label } } func quarterly(from, to time.Time) func() (time.Time, time.Time, string) { + pfrom := from return func() (time.Time, time.Time, string) { - // TODO: Implement me! - return time.Time{}, time.Time{}, "" + if pfrom.After(to) { + return time.Time{}, time.Time{}, "" + } + f := pfrom + pfrom = pfrom.AddDate(0, 3, 0) + label := fmt.Sprint("Q%d-%d", int(f.Month())/4+1, f.Year()) + return f, f.AddDate(0, 3, 0).Add(-time.Nanosecond), label } } func yearly(from, to time.Time) func() (time.Time, time.Time, string) { + pfrom := from return func() (time.Time, time.Time, string) { - // TODO: Implement me! - return time.Time{}, time.Time{}, "" + if pfrom.After(to) { + return time.Time{}, time.Time{}, "" + } + f := pfrom + pfrom = pfrom.AddDate(1, 0, 0) + label := fmt.Sprint("%d", f.Year()) + return f, f.AddDate(1, 0, 0).Add(-time.Nanosecond), label } }