diff --git a/status/timezones.go b/status/timezones.go index 8a9a5a48..0ffd2d8b 100644 --- a/status/timezones.go +++ b/status/timezones.go @@ -4,17 +4,16 @@ import ( "time" ) -func Timezones(timezones map[string]interface{}) map[string]time.Time { - times := make(map[string]time.Time) - - for label, timezone := range timezones { - tzloc, err := time.LoadLocation(timezone.(string)) +func Timezones(zones []string) []time.Time { + times := []time.Time{} + for _, zone := range zones { + loc, err := time.LoadLocation(zone) if err != nil { continue } - times[label] = time.Now().In(tzloc) + times = append(times, time.Now().In(loc)) } return times diff --git a/status/widget.go b/status/widget.go index 64ec0a91..5ba66cf3 100644 --- a/status/widget.go +++ b/status/widget.go @@ -2,7 +2,6 @@ package status import ( "fmt" - "sort" "strings" "time" @@ -62,25 +61,16 @@ func (widget *Widget) animation() string { } func (widget *Widget) timezones() string { - timezones := Timezones(Config.UMap("wtf.mods.status.timezones")) + times := Timezones(wtf.ToStrs(Config.UList("wtf.mods.status.timezones"))) - if len(timezones) == 0 { + if len(times) == 0 { return "" } - // All this is to display the time entries in alphabetical order - labels := []string{} - for label, _ := range timezones { - labels = append(labels, label) + formattedTimes := []string{} + for _, time := range times { + formattedTimes = append(formattedTimes, time.Format(wtf.TimeFormat)) } - sort.Strings(labels) - - tzs := []string{} - for _, label := range labels { - zoneStr := fmt.Sprintf("%s %s", label, timezones[label].Format(wtf.TimeFormat)) - tzs = append(tzs, zoneStr) - } - - return strings.Join(tzs, " ◦ ") + return strings.Join(formattedTimes, " • ") } diff --git a/wtf/config_files.go b/wtf/config_files.go index a38b740a..eeb28c5d 100644 --- a/wtf/config_files.go +++ b/wtf/config_files.go @@ -28,7 +28,6 @@ func LoadConfigFile(filePath string) *config.Config { cfg, err := config.ParseYamlFile(absPath) if err != nil { fmt.Println("\n\n\033[1m ERROR:\033[0m Could not load '\033[0;33mconfig.yml\033[0m'.\n Please add a \033[0;33mconfig.yml\033[0m file to your \033[0;33m~/.wtf\033[0m directory.\n See \033[1;34mhttps://github.com/senorprogrammer/wtf\033[0m for details.\n\n") - fmt.Println(err.Error()) os.Exit(1) } diff --git a/wtf/utils.go b/wtf/utils.go index 5832fcca..4bb486ba 100644 --- a/wtf/utils.go +++ b/wtf/utils.go @@ -10,7 +10,7 @@ import ( // DateFormat defines the format we expect to receive dates from BambooHR in const DateFormat = "2006-01-02" -const TimeFormat = "15:04" +const TimeFormat = "15:04 MST" func CenterText(str string, width int) string { return fmt.Sprintf("%[1]*s", -width, fmt.Sprintf("%[1]*s", (width+len(str))/2, str))