1
0

Refactor of ToClientTimezone that made it look better.

This commit is contained in:
Alexander Andreev 2022-04-02 04:30:46 +04:00
parent 6f607c830e
commit 4730e62808
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -22,11 +22,9 @@ func MainSite(host string) string {
// converts to UTC. // converts to UTC.
func ToClientTimezone(t time.Time, r *http.Request) time.Time { func ToClientTimezone(t time.Time, r *http.Request) time.Time {
if tz := r.Header.Get("X-Client-Timezone"); tz != "" { if tz := r.Header.Get("X-Client-Timezone"); tz != "" {
loc, err := time.LoadLocation(tz) if loc, err := time.LoadLocation(tz); err == nil {
if err != nil { return t.In(loc)
return t.UTC()
} }
return t.In(loc)
} }
return t.UTC() return t.UTC()
} }