From 1ccd19d78b2695a70ed06241197689288e01d5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Wed, 31 May 2023 09:40:28 +0800 Subject: [PATCH] =?UTF-8?q?enhance(utils):=E7=A7=BB=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=B7=A5=E5=85=B7=E5=87=BD=E6=95=B0=E5=8C=85=E7=9A=84?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/{ => time}/time.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) rename tools/{ => time}/time.go (55%) 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()