Refactor of ToClientTimezone that made it look better.
This commit is contained in:
parent
6f607c830e
commit
4730e62808
@ -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.UTC()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user