1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/clocks/display.go
Kirill Motkov f0771cd013 Some code improvements
* Some assignments simplified by using assignment operators
* Rewrite switch statement with only one case as if.
* Rewrite if-else chain as a switch statement.
* go fmt `modules/todoist/project.go` file.
2019-05-21 17:29:09 +03:00

33 lines
646 B
Go

package clocks
import (
"fmt"
)
func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat string) {
if len(clocks) == 0 {
title := fmt.Sprintf("\n%s", " no timezone data available")
widget.Redraw(widget.CommonSettings.Title, title, true)
return
}
str := ""
for idx, clock := range clocks {
rowColor := widget.settings.colors.rows.odd
if idx%2 == 0 {
rowColor = widget.settings.colors.rows.even
}
str += fmt.Sprintf(
" [%s]%-12s %-10s %7s[white]\n",
rowColor,
clock.Label,
clock.Time(timeFormat),
clock.Date(dateFormat),
)
}
widget.Redraw(widget.CommonSettings.Title, str, false)
}