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.
|
// 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()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user