mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 17:54:30 +08:00
prefer the value of X-Timezone-Name
This commit is contained in:
@@ -188,22 +188,23 @@ func (c *WebContext) GetClientLocale() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *WebContext) GetClientTimezone() (*time.Location, int16, error) {
|
func (c *WebContext) GetClientTimezone() (*time.Location, int16, error) {
|
||||||
utcOffset, err := c.getClientTimezoneOffset()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
timezoneName := c.getClientTimezoneName()
|
timezoneName := c.getClientTimezoneName()
|
||||||
|
|
||||||
if timezoneName != "" {
|
if timezoneName != "" {
|
||||||
location, err := time.LoadLocation(timezoneName)
|
location, err := time.LoadLocation(timezoneName)
|
||||||
|
|
||||||
if err == nil && location != nil {
|
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
|
return time.FixedZone("Client Fixed Timezone", int(utcOffset)*60), utcOffset, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user