mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
When `withDate` is `true`, it displays date information below the clock. When `withDate` is `false`, it does not display date information. Defaults to `true`. Signed-off-by: Chris Cummer <chriscummer@me.com>
33 lines
823 B
Go
33 lines
823 B
Go
package digitalclock
|
|
|
|
import "strings"
|
|
|
|
func mergeLines(outString []string) string {
|
|
return strings.Join(outString[:], "\n")
|
|
}
|
|
|
|
func renderWidget(widgetSettings Settings) string {
|
|
outputStrings := []string{}
|
|
|
|
clockString, needBorder := renderClock(widgetSettings)
|
|
if needBorder {
|
|
outputStrings = append(outputStrings, mergeLines([]string{"", clockString, ""}))
|
|
} else {
|
|
outputStrings = append(outputStrings, clockString)
|
|
}
|
|
|
|
if widgetSettings.withDate {
|
|
outputStrings = append(outputStrings, getDate())
|
|
outputStrings = append(outputStrings, getUTC())
|
|
outputStrings = append(outputStrings, getEpoch())
|
|
}
|
|
|
|
return mergeLines(outputStrings)
|
|
}
|
|
|
|
func (widget *Widget) display() {
|
|
widget.Redraw(func() (string, string, bool) {
|
|
return widget.CommonSettings().Title, renderWidget(*widget.settings), false
|
|
})
|
|
}
|