diff options
author | Martin Kraft <martinkraft@gmail.com> | 2018-03-23 09:08:49 -0400 |
---|---|---|
committer | Martin Kraft <martinkraft@gmail.com> | 2018-03-23 09:08:49 -0400 |
commit | 5fa1b3581955761bd39c310bc88b1489d963a9fc (patch) | |
tree | 25e6dd11592102807abebbb5de100f7d867005d8 /utils/timezone.go | |
parent | 37f0e5e0ebc0595efe2c65ffb84fa096dc8c5493 (diff) | |
parent | 87762ae62eb887dfb3fd0957040919aede46f7d4 (diff) | |
download | chat-5fa1b3581955761bd39c310bc88b1489d963a9fc.tar.gz chat-5fa1b3581955761bd39c310bc88b1489d963a9fc.tar.bz2 chat-5fa1b3581955761bd39c310bc88b1489d963a9fc.zip |
Merge branch 'master' into advanced-permissions-phase-1
Diffstat (limited to 'utils/timezone.go')
-rw-r--r-- | utils/timezone.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/utils/timezone.go b/utils/timezone.go new file mode 100644 index 000000000..ea5f15140 --- /dev/null +++ b/utils/timezone.go @@ -0,0 +1,25 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package utils + +import ( + "encoding/json" + "io/ioutil" + + "github.com/mattermost/mattermost-server/model" +) + +func LoadTimezones(fileName string) model.SupportedTimezones { + var supportedTimezones model.SupportedTimezones + + if timezoneFile := FindConfigFile(fileName); timezoneFile == "" { + return model.DefaultSupportedTimezones + } else if raw, err := ioutil.ReadFile(timezoneFile); err != nil { + return model.DefaultSupportedTimezones + } else if err := json.Unmarshal(raw, &supportedTimezones); err != nil { + return model.DefaultSupportedTimezones + } else { + return supportedTimezones + } +} |