bar/internal/providers/datetime.go
AKP 29ac240241
Update definition of i3bar.BlockGenerator
Signed-off-by: AKP <tom@tdpain.net>
2022-05-27 11:47:59 +01:00

32 lines
No EOL
551 B
Go

package providers
import (
"time"
"github.com/codemicro/bar/internal/i3bar"
)
type DateTime struct {
// TODO: 12 hour mode?
name string
}
func NewDateTime() i3bar.BlockGenerator {
return &DateTime{
name: "datetime",
}
}
func (g *DateTime) Block(*i3bar.ColorSet) (*i3bar.Block, error) {
cTime := time.Now().Local()
return &i3bar.Block{
Name: g.name,
FullText: cTime.Format("2006-01-02 15:04:05"),
ShortText: cTime.Format("15:04:05"),
}, nil
}
func (g *DateTime) GetNameAndInstance() (string, string) {
return g.name, ""
}