From 4730e62808404935d7e51f529c932e2c8b2fbeb6 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 2 Apr 2022 04:30:46 +0400 Subject: [PATCH] Refactor of ToClientTimezone that made it look better. --- pkg/utils/dwelling.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/utils/dwelling.go b/pkg/utils/dwelling.go index 23f178b..63e8a91 100644 --- a/pkg/utils/dwelling.go +++ b/pkg/utils/dwelling.go @@ -22,11 +22,9 @@ func MainSite(host string) string { // converts to UTC. func ToClientTimezone(t time.Time, r *http.Request) time.Time { if tz := r.Header.Get("X-Client-Timezone"); tz != "" { - loc, err := time.LoadLocation(tz) - if err != nil { - return t.UTC() + if loc, err := time.LoadLocation(tz); err == nil { + return t.In(loc) } - return t.In(loc) } return t.UTC() }