Round times to minutes for i3status

This commit is contained in:
Brian Buller 2021-03-04 14:04:56 -06:00
parent 61c3133bd2
commit 6ea133d20d

View File

@ -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.Sprint(wrk.Duration().Round(time.Second))
text = fmt.Sprintf("%d", mins)
}
} else {
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 {