diff --git a/route/cp_r/anniversary.go b/route/cp_r/anniversary.go index 2ad3e997900c48d31d82f249f42176b2692de26c..e3433ae2afdf3ed8318fb2ce4f856de1d845fe6a 100644 --- a/route/cp_r/anniversary.go +++ b/route/cp_r/anniversary.go @@ -14,7 +14,6 @@ import ( "hilo-user/req" "hilo-user/resp" "strconv" - "time" ) type PostPutAnniversaryReq struct { @@ -95,8 +94,8 @@ func PageAnniversary(c *gin.Context) (*mycontext.MyContext, error) { return myCtx, err } model := domain.CreateModelContext(myCtx) - loc, err := time.LoadLocation(c.GetHeader(mycontext.TIMEZONE)) - if err != nil { + loc := timezone_e.GetFixedTimezone(c.GetHeader(mycontext.TIMEZONE)) + if loc == nil { user, err := user_m.GetUser(model, userId) if err != nil { return myCtx, err diff --git a/route/cp_r/space.go b/route/cp_r/space.go index 1be7cc65fbf2885eacd4a688bb40e8ffb3e9b76b..656b2fd99b21b29592673da5a70773221642d073 100644 --- a/route/cp_r/space.go +++ b/route/cp_r/space.go @@ -36,8 +36,8 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) { if err != nil { return myContext, err } - loc, err := time.LoadLocation(c.GetHeader(mycontext.TIMEZONE)) - if err != nil { + loc := timezone_e.GetFixedTimezone(c.GetHeader(mycontext.TIMEZONE)) + if loc == nil { if userInfo.Language == "ar" { loc = timezone_e.KSATimezoneLoc } diff --git a/test/cp_test.go b/test/cp_test.go index 0974f13bafdbe0711c313fb7c1a6073418e423fa..fb41739721f5f97b0d987891842c89c7d2f519e1 100644 --- a/test/cp_test.go +++ b/test/cp_test.go @@ -1,9 +1,11 @@ package test import ( + "git.hilo.cn/hilo-common/_const/enum/timezone_e" "git.hilo.cn/hilo-common/domain" "hilo-user/domain/model/cp_m" "testing" + "time" ) func TestInitCpAnniversary(t *testing.T) { @@ -16,6 +18,15 @@ func TestInitCpAnniversary(t *testing.T) { } func TestCalcNextAnniversary(t *testing.T) { - t2 := cp_m.CalcNextAnniversary(1686211996) + t2 := cp_m.CalcNextAnniversary(1686211996, time.Local) println(t2) } + +func TestCalLoc(t *testing.T) { + loc := timezone_e.GetFixedTimezone("GMT+8") + println(time.Now().In(loc).Format("2006-01-02 15:04:05")) + loc = timezone_e.GetFixedTimezone("GMT+3") + println(time.Now().In(loc).Format("2006-01-02 15:04:05")) + loc = timezone_e.GetFixedTimezone("GMT+5") + println(time.Now().In(loc).Format("2006-01-02 15:04:05")) +}