timer/basicstopwatch.go

32 lines
458 B
Go
Executable File

package main
import (
"fmt"
)
type BasicStopwatch struct {
*Timer
}
func NewBasicStopwatch(t *Timer) string {
b := &BasicStopwatch{Timer: t}
return b.String()
}
func (t *BasicStopwatch) left() string {
cur := t.config.Duration - t.Remaining()
return fmt.Sprintf(
"%02d:%02d:%02d",
int(cur.Hours()),
int(cur.Minutes())%60,
int(cur.Seconds())%60,
)
}
func (t *BasicStopwatch) String() string {
return fmt.Sprintf(
"%s",
t.left(),
)
}