feat:增加用户资产和会员状态
This commit is contained in:
@ -66,3 +66,8 @@ func DiffTimeMonth(time1, time2 time.Time) int {
|
||||
month := math.Abs(float64(time1.Month()) - float64(time2.Month()))
|
||||
return int(year)*12 + int(month) + 1
|
||||
}
|
||||
|
||||
func DiffTimeDays(time1, time2 time.Time) int {
|
||||
sub := time1.Sub(time2)
|
||||
return int(math.Ceil(math.Abs(sub.Hours() / 24.0)))
|
||||
}
|
||||
|
9
utils/time_test.go
Normal file
9
utils/time_test.go
Normal file
@ -0,0 +1,9 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDiffTimeDays(t *testing.T) {
|
||||
time1 := DateTimeToTime("2022-05-06 23:59:59")
|
||||
time2 := DateTimeToTime("2022-05-04 01:59:59")
|
||||
t.Log(DiffTimeDays(time1, time2))
|
||||
}
|
Reference in New Issue
Block a user