diff options
| author | Hayden Hamilton <hayden@hhvn.uk> | 2026-06-03 16:25:12 +0100 |
|---|---|---|
| committer | Hayden Hamilton <hayden@hhvn.uk> | 2026-06-03 16:25:12 +0100 |
| commit | 25cd38bb49d22ffa42008a83ae86fba405fd2e14 (patch) | |
| tree | da4f93ae23f6cce1a9f1d6a0a750710810cd6ec4 | |
| parent | 4af147be6f35e2bf39174a5db88148c7efdda9bd (diff) | |
date+time status blocks have existed for a long time, but forgot to commit
| -rw-r--r-- | status/04-date.go | 31 | ||||
| -rw-r--r-- | status/05-time.go | 19 |
2 files changed, 50 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) +} diff --git a/status/05-time.go b/status/05-time.go new file mode 100644 index 0000000..0bdfbf7 --- /dev/null +++ b/status/05-time.go @@ -0,0 +1,19 @@ +package status // import "hhvn.uk/hbspbar/status" + +import ( + "time" + + "hhvn.uk/hbspbar/config" +) + +// TODO: twilight / weather +func timef(u *Block) error { + _, err := u.drawText(0, config.Fg, time.Now().Local().Format("15:04:05")) + if err != nil { return err } + + return nil +} + +func init() { + register("time", timef, 1) +} |