mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-09-04 09:13:24 +00:00
ENH - clock app
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
elapsedMilliseconds,
|
||||
formatStopwatch,
|
||||
formatTimer,
|
||||
remainingMilliseconds,
|
||||
timerPickerMilliseconds,
|
||||
@@ -18,4 +19,8 @@ describe('timestamp clocks', () => {
|
||||
expect(timerPickerValue(3_661_000)).toBe('01:01:01')
|
||||
expect(timerPickerMilliseconds('01:01:01')).toBe(3_661_000)
|
||||
})
|
||||
|
||||
it('formats stopwatch durations with actual milliseconds', () => {
|
||||
expect(formatStopwatch(61_234)).toBe('01:01.234')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -18,11 +18,11 @@ export function remainingMilliseconds(
|
||||
}
|
||||
|
||||
export function formatStopwatch(milliseconds: number): string {
|
||||
const totalCentiseconds = Math.floor(milliseconds / 10)
|
||||
const minutes = Math.floor(totalCentiseconds / 6000)
|
||||
const seconds = Math.floor((totalCentiseconds % 6000) / 100)
|
||||
const centiseconds = totalCentiseconds % 100
|
||||
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}.${String(centiseconds).padStart(2, '0')}`
|
||||
const totalMilliseconds = Math.floor(milliseconds)
|
||||
const minutes = Math.floor(totalMilliseconds / 60_000)
|
||||
const seconds = Math.floor((totalMilliseconds % 60_000) / 1000)
|
||||
const millisecondsPart = totalMilliseconds % 1000
|
||||
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}.${String(millisecondsPart).padStart(3, '0')}`
|
||||
}
|
||||
|
||||
export function formatTimer(milliseconds: number): string {
|
||||
|
||||
Reference in New Issue
Block a user