From b009c7b6e5a7f8ac275e28123342e764902745c9 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Thu, 25 Dec 2025 09:48:24 +0800 Subject: [PATCH] prefer the value of X-Timezone-Name --- pkg/core/context_web.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/core/context_web.go b/pkg/core/context_web.go index a2d1274b..1f907484 100644 --- a/pkg/core/context_web.go +++ b/pkg/core/context_web.go @@ -188,22 +188,23 @@ func (c *WebContext) GetClientLocale() string { } func (c *WebContext) GetClientTimezone() (*time.Location, int16, error) { - utcOffset, err := c.getClientTimezoneOffset() - - if err != nil { - return nil, 0, err - } - timezoneName := c.getClientTimezoneName() if timezoneName != "" { location, err := time.LoadLocation(timezoneName) if err == nil && location != nil { - return location, utcOffset, nil + _, tzOffset := time.Now().In(location).Zone() + return location, int16(tzOffset / 60), nil } } + utcOffset, err := c.getClientTimezoneOffset() + + if err != nil { + return nil, 0, err + } + return time.FixedZone("Client Fixed Timezone", int(utcOffset)*60), utcOffset, nil }