From 6ea133d20dcc55fb836c103e4c53e58b0650179c Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Thu, 4 Mar 2021 14:04:56 -0600 Subject: [PATCH] Round times to minutes for i3status --- timer_ops.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/timer_ops.go b/timer_ops.go index 1832c63..ab20533 100644 --- a/timer_ops.go +++ b/timer_ops.go @@ -18,11 +18,19 @@ func (a *AppState) opI3Status(args []string) int { return 0 } + // TODO: Get Weekly/Daily totals var text string if wrk.Finished { - text = fmt.Sprint(wrk.Duration().Round(time.Minute * 15)) + wrkDur := wrk.Duration().Round(time.Minute * 15) + hrs := int(wrkDur.Hours()) + mins := int(wrkDur.Minutes()) - hrs*60 + if hrs > 0 { + text = fmt.Sprintf("%dh%dm", hrs, mins) + } else { + text = fmt.Sprintf("%d", mins) + } } else { - text = fmt.Sprint(wrk.Duration().Round(time.Second)) + text = fmt.Sprint(wrk.Duration().Round(time.Minute)) // If the current time is before 7AM, after 5PM, or a weekend, use a Warning state cTime := time.Now() if cTime.Weekday() == time.Sunday || cTime.Weekday() == time.Saturday || cTime.Hour() < 7 || cTime.Hour() > 17 {