39 lines
549 B
Go
39 lines
549 B
Go
package times
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
loc *time.Location
|
|
)
|
|
|
|
func init() {
|
|
loc, _ = time.LoadLocation("Asia/Novosibirsk")
|
|
}
|
|
|
|
func GetNow() time.Time {
|
|
t := time.Now().In(loc)
|
|
return t
|
|
}
|
|
|
|
func GetStartDay() time.Time {
|
|
t := GetNow()
|
|
t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, loc)
|
|
return t
|
|
}
|
|
|
|
func GetStartDayMinus(days int) time.Time {
|
|
t := GetStartDay()
|
|
for i := 0; i < days; i++ {
|
|
t = t.Add(-24 * time.Hour)
|
|
}
|
|
return t
|
|
}
|
|
|
|
func GetStartWeek() time.Time {
|
|
t := GetStartDay()
|
|
t = t.Add(-6 * 24 * time.Hour)
|
|
return t
|
|
}
|