diff options
author | Corey Hulen <corey@hulen.com> | 2015-11-30 08:51:36 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-11-30 08:51:36 -0800 |
commit | 93f08717a8cf40b1e3be138ed9d5b4d76fcfadb9 (patch) | |
tree | 4b81b2c63329364cb391427b61a1ab7f2bd5969f /utils/time.go | |
parent | ce259ad7f1ce8a52b7fc5af7542a101acf71173e (diff) | |
parent | 7ac97273855e5e68d9e4b10e96d5466201fb8871 (diff) | |
download | chat-93f08717a8cf40b1e3be138ed9d5b4d76fcfadb9.tar.gz chat-93f08717a8cf40b1e3be138ed9d5b4d76fcfadb9.tar.bz2 chat-93f08717a8cf40b1e3be138ed9d5b4d76fcfadb9.zip |
Merge pull request #1537 from florianorben/PLT-1035
PLT-1035: Remove last data point in graphs on #statistics page
Diffstat (limited to 'utils/time.go')
-rw-r--r-- | utils/time.go | 23 |
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) +} |