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

Cleanup of stray files. Don't need so many single-use packages

This commit is contained in:
Chris Cummer
2018-04-18 17:51:43 -07:00
parent 5e186323e0
commit 12ef3919dc
9 changed files with 46 additions and 59 deletions

32
clocks/display.go Normal file
View File

@@ -0,0 +1,32 @@
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"))
}

View File

@@ -1,9 +1,7 @@
package clocks
import (
"fmt"
"sort"
"strings"
"time"
"github.com/olebedev/config"
@@ -52,32 +50,6 @@ func (widget *Widget) colorFor(idx int) string {
return rowColor
}
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"))
}
func (widget *Widget) locations(locs map[string]interface{}) map[string]time.Time {
times := make(map[string]time.Time)