From 808318928a6a8316f7d5e33bd88f128ce86e899e Mon Sep 17 00:00:00 2001 From: nuintun Date: Tue, 11 Jun 2024 00:00:32 +0800 Subject: [PATCH] feat: Update code --- app/js/pages/Home/index.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/js/pages/Home/index.tsx b/app/js/pages/Home/index.tsx index 38128871..87885fb4 100644 --- a/app/js/pages/Home/index.tsx +++ b/app/js/pages/Home/index.tsx @@ -64,14 +64,16 @@ const LineChart = memo(({ theme }: LineChartProps) => { ); }); -function formatTime(time: number): string { - const mins = Math.floor(time / 600); - const secs = Math.floor(time / 10) % 60; - const ms = Math.floor(time % 10); +function pad(value: number): string { + return value.toString().padStart(2, '0'); +} - if (secs < 10) return `${mins}:0${secs}.${ms}`; +function formatTime(time: number): string { + const secs = time % 60; + const mins = Math.floor(time / 60) % 60; + const hours = Math.floor(time / 3600); - return `${mins}:${secs}.${ms}`; + return `${pad(hours)}:${pad(mins)}:${pad(secs)}`; } function requestInterval(callback: (...args: any[]) => void, interval: number): () => void {