updates
All checks were successful
build / build (push) Successful in 6s

This commit is contained in:
Tijl 2024-09-27 18:05:35 +02:00
parent e7a16c663a
commit 69dcd8418a
Signed by: tijl
GPG Key ID: DAE24BFCD722F053

11
main.go
View File

@ -116,6 +116,7 @@ func stopwatchUI(startTime time.Time) {
go func() { go func() {
<-stop <-stop
fmt.Println()
os.Exit(0) os.Exit(0)
}() }()
@ -137,22 +138,22 @@ func timerUI(startTime time.Time) {
go func() { go func() {
<-stop <-stop
fmt.Printf("\n") fmt.Println()
os.Exit(0) os.Exit(0)
}() }()
for { for {
elapsed := time.Until(startTime) elapsed := time.Until(startTime)
if elapsed.Milliseconds() == 0 {
fmt.Printf("\n")
break
}
fmt.Printf("\r%02dd %02dh %02dm %02ds %03dms", fmt.Printf("\r%02dd %02dh %02dm %02ds %03dms",
elapsed/(24*time.Hour), elapsed/(24*time.Hour),
(elapsed%(24*time.Hour))/time.Hour, (elapsed%(24*time.Hour))/time.Hour,
(elapsed%time.Hour)/time.Minute, (elapsed%time.Hour)/time.Minute,
(elapsed%time.Minute)/time.Second, (elapsed%time.Minute)/time.Second,
(elapsed%time.Second)/time.Millisecond) (elapsed%time.Second)/time.Millisecond)
if elapsed.Milliseconds() == 0 {
fmt.Println()
break
}
time.Sleep(1 * time.Millisecond) time.Sleep(1 * time.Millisecond)
} }
} }