Add clock module
parent
0d3cbdac24
commit
325eacbfdb
|
@ -0,0 +1,19 @@
|
|||
package statusscreen
|
||||
|
||||
import (
|
||||
"github.com/common-nighthawk/go-figure"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Clock is my Clock struct
|
||||
type Clock struct {
|
||||
Config *Config
|
||||
}
|
||||
|
||||
// GetOutput returns a rendered result of this module
|
||||
func (clock *Clock) GetOutput() []string {
|
||||
currentTime := time.Now().Format(clock.Config.Clock.TimeFormat)
|
||||
myFigure := figure.NewFigure(currentTime, "", true)
|
||||
|
||||
return myFigure.Slicify()
|
||||
}
|
|
@ -8,4 +8,7 @@ type Config struct {
|
|||
SiteID int
|
||||
APIURL string
|
||||
}
|
||||
Clock struct {
|
||||
TimeFormat string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,3 +3,6 @@ APIKey = "insert-your-api-key-here"
|
|||
RefreshDelay = 300
|
||||
SiteID = 1234
|
||||
APIURL = "https://api.sl.se/api2/realtimedeparturesV4.json?key=%s&siteid=%d&timewindow=60"
|
||||
|
||||
[Clock]
|
||||
TimeFormat = "15:04:05"
|
||||
|
|
Loading…
Reference in New Issue