changeset 5302:110277a1f74c

Merged
author Sascha Wilde <wilde@intevation.de>
date Wed, 11 Nov 2020 11:16:40 +0100
parents 955196acfcb5 (current diff) 71f73df1356d (diff)
children da04fa72cee8
files
diffstat 3 files changed, 26 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- 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())
+}
--- 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 {