summaryrefslogtreecommitdiffstats
path: root/app/timezone.go
blob: 84d912da68b242fbc1ac970c7de3977c584636db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package app

import (
	"github.com/mattermost/mattermost-server/model"
	"github.com/mattermost/mattermost-server/utils"
)

func (a *App) Timezones() model.SupportedTimezones {
	if cfg := a.timezones.Load(); cfg != nil {
		return cfg.(model.SupportedTimezones)
	}
	return model.SupportedTimezones{}
}

func (a *App) LoadTimezones() {
	timezonePath := "timezones.json"

	if a.Config().TimezoneSettings.SupportedTimezonesPath != nil && len(*a.Config().TimezoneSettings.SupportedTimezonesPath) > 0 {
		timezonePath = *a.Config().TimezoneSettings.SupportedTimezonesPath
	}

	timezoneCfg := utils.LoadTimezones(timezonePath)

	a.timezones.Store(timezoneCfg)
}