feat 初始化
This commit is contained in:
26
utils/time.go
Normal file
26
utils/time.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CalcDaysDiff 计算两个日期相差多少天
|
||||
func CalcDaysDiff(one, two time.Time) int32 {
|
||||
oneZero := time.Date(
|
||||
one.Year(),
|
||||
one.Month(),
|
||||
one.Day(),
|
||||
0, 0, 0, 0,
|
||||
time.Local,
|
||||
)
|
||||
twoZero := time.Date(
|
||||
two.Year(),
|
||||
two.Month(),
|
||||
two.Day(),
|
||||
0, 0, 0, 0,
|
||||
time.Local,
|
||||
)
|
||||
// 计算相差天数
|
||||
return int32(math.Abs(oneZero.Sub(twoZero).Hours() / 24))
|
||||
}
|
||||
Reference in New Issue
Block a user