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:
32
clocks/display.go
Normal file
32
clocks/display.go
Normal 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"))
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user