mirror of
https://github.com/taigrr/wtf
synced 2026-03-21 14:12:17 -07:00
Adds support for digital clock
This commit is contained in:
28
modules/digitalclock/display.go
Normal file
28
modules/digitalclock/display.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
}
|
||||
outputStrings = append(outputStrings, getDate())
|
||||
outputStrings = append(outputStrings, getUTC())
|
||||
outputStrings = append(outputStrings, getEpoch())
|
||||
return mergeLines(outputStrings)
|
||||
}
|
||||
|
||||
func (widget *Widget) display(dateFormat string, timeFormat string) {
|
||||
widget.Redraw(func() (string, string, bool) {
|
||||
return widget.CommonSettings().Title, renderWidget(*widget.settings), false
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user