diff options
Diffstat (limited to 'status/04-date.go')
| -rw-r--r-- | status/04-date.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/status/04-date.go b/status/04-date.go new file mode 100644 index 0000000..cd8f7f2 --- /dev/null +++ b/status/04-date.go @@ -0,0 +1,31 @@ +package status // import "hhvn.uk/hbspbar/status" + +import ( + "time" + + "hhvn.uk/hbspbar/config" +) + +var datewait = false + +// TODO: seasons +func date(b *Block) error { + // opposite of sync.Once + if !datewait { + datewait = true + } else { + // Sleep til the next day comes around + tmrw := time.Now().AddDate(0, 0, 1) + tmrw = time.Date(tmrw.Year(), tmrw.Month(), tmrw.Day(), 0, 0, 0, 0, time.Local) + time.Sleep(time.Until(tmrw)) + } + + _, err := b.drawText(0, config.Fg, time.Now().Local().Format("Mon 02/01")) + if err != nil { return err } + + return nil +} + +func init() { + register("date", date, 0) +} |