# HG changeset patch # User Sascha Wilde # Date 1605089800 -3600 # Node ID 110277a1f74c346d2e6ee2be4ed389ae9a45c16b # Parent 955196acfcb5f2549faab06b176650ea4ca49e10# Parent 71f73df1356d8406ea695ea7d79902565b505516 Merged diff -r 955196acfcb5 -r 110277a1f74c docker/Dockerfile.pg --- a/docker/Dockerfile.pg Wed Nov 11 11:09:07 2020 +0100 +++ b/docker/Dockerfile.pg Wed Nov 11 11:16:40 2020 +0100 @@ -29,7 +29,7 @@ WORKDIR /opt/ RUN git clone https://git.osgeo.org/gitea/postgis/postgis.git WORKDIR /opt/postgis -RUN git checkout svn-2.5 +RUN git checkout stable-2.5 RUN ./autogen.sh && ./configure --with-pgconfig=$PGBIN/pg_config && \ make comments && make && make install diff -r 955196acfcb5 -r 110277a1f74c pkg/common/time.go --- a/pkg/common/time.go Wed Nov 11 11:09:07 2020 +0100 +++ b/pkg/common/time.go Wed Nov 11 11:16:40 2020 +0100 @@ -98,6 +98,7 @@ } } +// MinTime returns the earlier time of a and b. func MinTime(a, b time.Time) time.Time { if a.Before(b) { return a @@ -105,6 +106,7 @@ return b } +// MaxTime returns the later time of a and b. func MaxTime(a, b time.Time) time.Time { if a.After(b) { return a @@ -112,9 +114,30 @@ return b } +// OrderTime orders the times a and b ascendingly. func OrderTime(a, b time.Time) (time.Time, time.Time) { if a.Before(b) { return a, b } return b, a } + +// Dusk returns the beginning of the day the time t is in. +func Dusk(t time.Time) time.Time { + return time.Date( + t.Year(), + t.Month(), + t.Day(), + 0, 0, 0, 0, + t.Location()) +} + +// Dawn returns the last time of the day the time t is in. +func Dawn(t time.Time) time.Time { + return time.Date( + t.Year(), + t.Month(), + t.Day(), + 23, 59, 59, 999999999, + t.Location()) +} diff -r 955196acfcb5 -r 110277a1f74c pkg/controllers/fwa.go --- a/pkg/controllers/fwa.go Wed Nov 11 11:09:07 2020 +0100 +++ b/pkg/controllers/fwa.go Wed Nov 11 11:16:40 2020 +0100 @@ -342,7 +342,7 @@ } // Stop yesterday - end := common.MinTime(dusk(time.Now()).Add(-time.Nanosecond), to) + end := common.MinTime(common.Dusk(time.Now()).Add(-time.Nanosecond), to) // We step through the time in steps of one day. for current = from; current.Before(end); { @@ -456,24 +456,6 @@ return len(classes) - 1 } -func dusk(t time.Time) time.Time { - return time.Date( - t.Year(), - t.Month(), - t.Day(), - 0, 0, 0, 0, - t.Location()) -} - -func dawn(t time.Time) time.Time { - return time.Date( - t.Year(), - t.Month(), - t.Day(), - 23, 59, 59, 999999999, - t.Location()) -} - func parseFromTo( rw http.ResponseWriter, req *http.Request, @@ -490,7 +472,7 @@ from, to = common.OrderTime(from, to) // Operate on daily basis so go to full days. - return dusk(from), dawn(to), true + return common.Dusk(from), common.Dawn(to), true } func parseFWAMode(mode string) fwaMode {