forked from ddrilling/asb_cloud_front
Добавлена функция вывода длительности в формате ЧЧ:ММ:СС
This commit is contained in:
parent
cf7323ba5a
commit
99292bd80d
10
src/utils/datetime.ts
Normal file
10
src/utils/datetime.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export const periodToString = (time?: number) => {
|
||||
if (!time) return '00:00:00'
|
||||
const hours = Math.floor(time / 3600)
|
||||
const minutes = Math.floor(time / 60 - hours * 60)
|
||||
const seconds = Math.floor(time - hours * 3600 - minutes * 60)
|
||||
|
||||
const toFixed = (num: number) => `${num}`.padStart(2, '0')
|
||||
|
||||
return `${toFixed(hours)}:${toFixed(minutes)}:${toFixed(seconds)}`
|
||||
}
|
Loading…
Reference in New Issue
Block a user