mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Prepare file upload infrastructure for Data Retention. This commit prepares the file upload infrastructure for the data retention feature that is under construction. Changes are: * Move file management code to utils to allow access to it from jobs. * From now on, store all file uploads in a top level folder which is the date of the day on which they were uploaded. This commit is based on Harrison Healey's branch, but updated to work with the latest master. * Use NewAppError
28 lines
577 B
Go
28 lines
577 B
Go
package utils
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func MillisFromTime(t time.Time) int64 {
|
|
return t.UnixNano() / int64(time.Millisecond)
|
|
}
|
|
|
|
func TimeFromMillis(millis int64) time.Time {
|
|
return time.Unix(0, millis*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)
|
|
}
|