31 lines
698 B
Go
31 lines
698 B
Go
package utils
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// 判断时间点处于今天
|
|
func IsToday(d int64) bool {
|
|
tt := time.Unix(d, 0)
|
|
now := time.Now()
|
|
return tt.Year() == now.Year() && tt.Month() == now.Month() && tt.Day() == now.Day()
|
|
}
|
|
|
|
//判断是否大于1周
|
|
func IsAfterWeek(d int64) bool {
|
|
tt := time.Unix(d, 0)
|
|
now := time.Now()
|
|
if !tt.Before(now) {
|
|
return false
|
|
}
|
|
return now.Sub(tt) >= time.Hour*24*7
|
|
}
|
|
|
|
// 获取当前时间戳下一天0点时间戳
|
|
func GetZeroTime(curTime int64) int64 {
|
|
currentTime := time.Unix(curTime, 0)
|
|
startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location())
|
|
|
|
return startTime.Unix() + 86400 //3600*24
|
|
}
|