32 lines
No EOL
551 B
Go
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, ""
|
|
} |