32 lines
710 B
Go
32 lines
710 B
Go
package time
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
var Loc *time.Location = time.FixedZone("+0800", 8*60*60)
|
|
|
|
func Now() time.Time {
|
|
return time.Now().In(Loc)
|
|
}
|
|
|
|
func Time(year int, month time.Month, date, hours, min, sec, nsec int) time.Time {
|
|
return time.Date(year, month, date, hours, min, sec, nsec, Loc)
|
|
}
|
|
|
|
func Timestamp() int64 {
|
|
startline := time.Date(2022, 2, 22, 22, 22, 22, 0, Loc).Unix()
|
|
return Now().Unix() - startline
|
|
}
|
|
|
|
func DifferenceInMonth(t1, t2 time.Time) int {
|
|
var differYear, differMonth int
|
|
differYear = t1.Year() - t2.Year()
|
|
differMonth = int(t1.Month() - t2.Month())
|
|
return differYear*12 + differMonth
|
|
}
|
|
|
|
func IsNextMonth(origin, t time.Time) bool {
|
|
return DifferenceInMonth(t, origin) == 1
|
|
}
|