Mercurial > gemma
changeset 3122:3dffeb6df4a3
Display Available Fairway Depths: Implemented monthly, quarterly and yearly stepping through the measurements.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Apr 2019 11:58:20 +0200 |
parents | adca192a4070 |
children | f0af359391a0 |
files | pkg/controllers/bottlenecks.go |
diffstat | 1 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 } }