Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
#109 Use time.Now().Location() as-is (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
grubbins authored and scottleedavis committed May 28, 2019
1 parent f60e6a5 commit f2fc596
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/mattermost/mattermost-server/model"
"github.com/nicksnyder/go-i18n/i18n"
"github.com/tkuchiki/go-timezone"
)

func (p *Plugin) translation(user *model.User) (i18n.TranslateFunc, string) {
Expand All @@ -22,21 +21,8 @@ func (p *Plugin) translation(user *model.User) (i18n.TranslateFunc, string) {
func (p *Plugin) location(user *model.User) *time.Location {
tz := user.GetPreferredTimezone()
if tz == "" {
tzCode, _ := time.Now().Zone()

if tzLoc, err := timezone.GetTimezones(tzCode); err != nil {
return time.Now().Location()
} else {
if len(tzLoc) > 0 {
if l, lErr := time.LoadLocation(tzLoc[0]); lErr != nil {
return time.Now().Location()
} else {
return l
}
} else {
return time.Now().Location()
}
}
// Use server's timezone
return time.Now().Location()
} else {
location, _ := time.LoadLocation(tz)
return location
Expand Down

0 comments on commit f2fc596

Please sign in to comment.