From 367dc1ea5ce1548d01688fda6baa5c9861f964e1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 11 Mar 2023 11:00:11 +0900 Subject: fix(timer): fix a crash when duration is longer than 1 minute --- cmd/timer.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/timer.go b/cmd/timer.go index 0e0ff48..aca2380 100644 --- a/cmd/timer.go +++ b/cmd/timer.go @@ -21,18 +21,18 @@ func drawTimer(scr *term.Screen, leftTime time.Duration, bgStyle, fgStyle term.S squareW, squareH, xOffset, yOffset := calcSquareSize(scr) // Minute - minute := leftTime.Minutes() - term.DrawNumber(scr, int(minute)/10, xOffset+squareW*0, yOffset, squareW, squareH, fgStyle) - term.DrawNumber(scr, int(minute)%10, xOffset+squareW*4, yOffset, squareW, squareH, fgStyle) + minute := int(leftTime.Minutes()) + term.DrawNumber(scr, minute/10, xOffset+squareW*0, yOffset, squareW, squareH, fgStyle) + term.DrawNumber(scr, minute%10, xOffset+squareW*4, yOffset, squareW, squareH, fgStyle) // Colon term.DrawSquare(scr, xOffset+squareW*8, yOffset+squareH*1, squareW, squareH, fgStyle) term.DrawSquare(scr, xOffset+squareW*8, yOffset+squareH*3, squareW, squareH, fgStyle) // Second - second := leftTime.Seconds() - term.DrawNumber(scr, int(second)/10, xOffset+squareW*10, yOffset, squareW, squareH, fgStyle) - term.DrawNumber(scr, int(second)%10, xOffset+squareW*14, yOffset, squareW, squareH, fgStyle) + second := int(leftTime.Seconds()) % 60 + term.DrawNumber(scr, second/10, xOffset+squareW*10, yOffset, squareW, squareH, fgStyle) + term.DrawNumber(scr, second%10, xOffset+squareW*14, yOffset, squareW, squareH, fgStyle) } func cmdTimer(cmd *cobra.Command, args []string) { -- cgit v1.2.3-70-g09d2