summaryrefslogtreecommitdiffstats
path: root/utils/time.go
diff options
context:
space:
mode:
authorFlorian Orben <florian.orben@gmail.com>2015-11-28 14:56:30 +0100
committerFlorian Orben <florian.orben@gmail.com>2015-11-28 16:26:24 +0100
commit7ac97273855e5e68d9e4b10e96d5466201fb8871 (patch)
tree4411424be6281887a713d20ee383906e59b75168 /utils/time.go
parent42a001c4e26acaebb7bade2a9b45428578b04164 (diff)
downloadchat-7ac97273855e5e68d9e4b10e96d5466201fb8871.tar.gz
chat-7ac97273855e5e68d9e4b10e96d5466201fb8871.tar.bz2
chat-7ac97273855e5e68d9e4b10e96d5466201fb8871.zip
PLT-1035: Remove last data point in graphs on #statistics page
Diffstat (limited to 'utils/time.go')
-rw-r--r--utils/time.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/utils/time.go b/utils/time.go
new file mode 100644
index 000000000..7d5afdf8f
--- /dev/null
+++ b/utils/time.go
@@ -0,0 +1,23 @@
+package utils
+
+import (
+ "time"
+)
+
+func MillisFromTime(t time.Time) int64 {
+ return t.UnixNano() / int64(time.Millisecond)
+}
+
+func StartOfDay(t time.Time) time.Time {
+ year, month, day := t.Date()
+ return time.Date(year, month, day, 0, 0, 0, 0, t.Location())
+}
+
+func EndOfDay(t time.Time) time.Time {
+ year, month, day := t.Date()
+ return time.Date(year, month, day, 23, 59, 59, 999999999, t.Location())
+}
+
+func Yesterday() time.Time {
+ return time.Now().AddDate(0, 0, -1)
+}