diff --git a/tools/time.go b/tools/time/time.go similarity index 55% rename from tools/time.go rename to tools/time/time.go index c69b0fb..5bbd36b 100644 --- a/tools/time.go +++ b/tools/time/time.go @@ -1,9 +1,20 @@ -package tools +package time import ( "time" ) +var loc *time.Location = time.FixedZone("+0800", 8*60*60) + +func Now() time.Time { + return time.Now().In(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()