Round times to minutes for i3status
This commit is contained in:
parent
61c3133bd2
commit
6ea133d20d
12
timer_ops.go
12
timer_ops.go
@ -18,11 +18,19 @@ func (a *AppState) opI3Status(args []string) int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Get Weekly/Daily totals
|
||||||
var text string
|
var text string
|
||||||
if wrk.Finished {
|
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 {
|
} 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
|
// If the current time is before 7AM, after 5PM, or a weekend, use a Warning state
|
||||||
cTime := time.Now()
|
cTime := time.Now()
|
||||||
if cTime.Weekday() == time.Sunday || cTime.Weekday() == time.Saturday || cTime.Hour() < 7 || cTime.Hour() > 17 {
|
if cTime.Weekday() == time.Sunday || cTime.Weekday() == time.Saturday || cTime.Hour() < 7 || cTime.Hour() > 17 {
|
||||||
|
Loading…
Reference in New Issue
Block a user