From 98471cb09b77295fa69cbc307a024bd68ff85851 Mon Sep 17 00:00:00 2001 From: halvo Date: Fri, 24 Jun 2022 00:09:06 -0400 Subject: [PATCH 1/3] fixed display of hour plus long tracks --- hooks/useMsToTime.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hooks/useMsToTime.ts b/hooks/useMsToTime.ts index 136c48e..0640b02 100644 --- a/hooks/useMsToTime.ts +++ b/hooks/useMsToTime.ts @@ -8,8 +8,15 @@ export function useMsToTime(s: number) { const secs = s % 60 s = (s - secs) / 60 const mins = s % 60 + s = (s - mins) / 60 + const hour = s + const hourString = formatToString(hour) const minsString = formatToString(mins) const secsString = formatToString(secs) - return minsString + ':' + secsString + if (s == 0) { + return minsString + ':' + secsString + } else { + return hourString + ':' + minsString + ':' + secsString + } } From c271d00f6cafaff46710747e39a725258b6325cc Mon Sep 17 00:00:00 2001 From: halvo Date: Fri, 24 Jun 2022 17:25:21 -0400 Subject: [PATCH 2/3] added time tests for hours --- hooks/__tests__/useMsToTime.tests.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hooks/__tests__/useMsToTime.tests.ts b/hooks/__tests__/useMsToTime.tests.ts index ecb7552..7ab527c 100644 --- a/hooks/__tests__/useMsToTime.tests.ts +++ b/hooks/__tests__/useMsToTime.tests.ts @@ -25,4 +25,9 @@ describe('useMsToTime unit tests', () => { const minutes = useMsToTime(1335000) expect(minutes).toBe('22:15') }) + + it('given 6443000 ms, should return 01:47:23', () => { + const minutes = useMsToTime(6443000) + expect(minutes).toBe('01:47:23') + }) }) From 2bce04a0d095f6c79a79cc9c7414b472b86ced3c Mon Sep 17 00:00:00 2001 From: Adrian Carolli Date: Mon, 3 Jul 2023 13:25:37 -0400 Subject: [PATCH 3/3] Update hooks/useMsToTime.ts --- hooks/useMsToTime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/useMsToTime.ts b/hooks/useMsToTime.ts index 0640b02..2532bab 100644 --- a/hooks/useMsToTime.ts +++ b/hooks/useMsToTime.ts @@ -14,7 +14,7 @@ export function useMsToTime(s: number) { const minsString = formatToString(mins) const secsString = formatToString(secs) - if (s == 0) { + if (s === 0) { return minsString + ':' + secsString } else { return hourString + ':' + minsString + ':' + secsString