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
1 changed files with 10 additions and 2 deletions

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.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 {