/
vasya2
/
var2
Обзор
Документация
Войти
/
vasya2
/
var2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
client/src/utils/format-seconds.ts
15 строк
466 B
Tom
fix(client): make exam client work with new endpoints (#51125)
09 авг 2023, 11:29
Не верифицирован
09 авг 2023, 11:29
2eef45a
Код
Авторство
О чём код?
export function formatSecondsToTime(s: number) { const hourInSeconds = 60 * 60; const minuteInSeconds = 60; const h = Math.floor(s / hourInSeconds); s -= h * hourInSeconds; const minutes = Math.floor(s / minuteInSeconds); s -= minutes * minuteInSeconds; const mm = minutes < 10 && h >= 1 ? `0${minutes}` : minutes; const seconds = s % 60; const ss = seconds < 10 ? `0${seconds}` : seconds; return h > 0 ? `${h}:${mm}:${ss}` : `${mm}:${ss}`; }