timer/with.go

40 lines
534 B
Go

package main
import (
"fmt"
"time"
)
func WithETA(typed Typed) Typed {
return func(t *Timer) string {
s := typed(t)
return fmt.Sprintf(
"%s\tETA: %s",
s,
t.Deadline().Format("15:04:05"),
)
}
}
func WithDone(typed Typed) Typed {
return func(t *Timer) string {
s := typed(t)
return fmt.Sprintf(
"%s\tDone: %v",
s,
t.Done(),
)
}
}
func WithTS(typed Typed) Typed {
return func(t *Timer) string {
s := typed(t)
return fmt.Sprintf(
"%s:\t%s",
time.Now().Format("15:04:05"),
s,
)
}
}