Add clock module

master
Elis Hirwing 2017-11-04 12:12:06 +01:00
parent 0d3cbdac24
commit 325eacbfdb
Signed by: etu
GPG Key ID: D57EFA625C9A925F
3 changed files with 25 additions and 0 deletions

19
src/statusscreen/Clock.go Normal file
View File

@ -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()
}

View File

@ -8,4 +8,7 @@ type Config struct {
SiteID int
APIURL string
}
Clock struct {
TimeFormat string
}
}

View File

@ -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"