From 7da2133290fb4259bc9800cfe60028faeca19514 Mon Sep 17 00:00:00 2001 From: "LinskRuis.32G" Date: Sat, 24 Apr 2021 00:24:41 +0800 Subject: [PATCH] time zone --- core/comms/const.go | 7 ++++++- core/utils/{code.go => util.go} | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) rename core/utils/{code.go => util.go} (88%) diff --git a/core/comms/const.go b/core/comms/const.go index 3b381fc..dbccefa 100644 --- a/core/comms/const.go +++ b/core/comms/const.go @@ -1,6 +1,9 @@ package comms -import "regexp" +import ( + "regexp" + "time" +) const ( TimeZero = -62135596800 @@ -12,6 +15,8 @@ const ( ) var ( + TimeZHT = time.FixedZone("CST", 8*3600) + REG_Host = regexp.MustCompile(`((\w+\.)*)((jzdisk\.)\w+)(:\d+)?`) REG_Hosts = regexp.MustCompile(`https?://((\w+\.)*)((1ydt\.)\w+)(:\d+)?`) REG_Phone = regexp.MustCompile(`^([0-9]{0,3})[1][3,4,5,7,8,9][0-9]{9}$`) diff --git a/core/utils/code.go b/core/utils/util.go similarity index 88% rename from core/utils/code.go rename to core/utils/util.go index 22c2acd..83966f1 100644 --- a/core/utils/code.go +++ b/core/utils/util.go @@ -8,6 +8,10 @@ import ( "time" ) +func ZHTNow() time.Time { + return time.Now().In(comms.TimeZHT) +} + func GenValidateCode(width int) string { numeric := [10]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} r := len(numeric)