dtp/util/util.go

26 lines
537 B
Go

package util
import (
"fmt"
"math"
"time"
)
// 获取0点时间戳
func GetDayStartTimeStamp(t time.Time) int64 {
loc, err := time.LoadLocation("Asia/Shanghai")
if err != nil {
loc = time.FixedZone("CST", 8*3600)
}
timeStr := fmt.Sprintf("%02d-%02d-%02d 00:00:00", t.Year(), t.Month(), t.Day())
duetimecst, err := time.ParseInLocation("2006-1-2 15:04:05", timeStr, loc)
if err != nil {
fmt.Printf("parse error : %v\n", err)
}
return duetimecst.Unix()
}
func RoundUp(num float64) int64 {
return int64(math.Ceil(num))
}