1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/clocks/display.go

33 lines
604 B
Go

package clocks
import (
"fmt"
"strings"
)
func (widget *Widget) display() {
locs := widget.locations(Config.UMap("wtf.mods.clocks.locations"))
if len(locs) == 0 {
fmt.Fprintf(widget.View, "\n%s", " no timezone data available")
return
}
labels := widget.sortedLabels(locs)
tzs := []string{}
for idx, label := range labels {
zoneStr := fmt.Sprintf(
" [%s]%-12s %-10s %7s[white]",
widget.colorFor(idx),
label,
locs[label].Format(TimeFormat),
locs[label].Format(DateFormat),
)
tzs = append(tzs, zoneStr)
}
fmt.Fprintf(widget.View, "\n%s", strings.Join(tzs, "\n"))
}