aboutsummaryrefslogtreecommitdiff
path: root/src/utils/convertTimeToString.ts
blob: 098f34a5bbe3fd4530c838de78bf239383b6310e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export default (timeDelta: number): string => {
  let resultTime = '';

  const minute = Math.floor(timeDelta / 60000);
  if (minute < 10) resultTime += '0';
  resultTime += minute + ':';

  let second = Math.floor(timeDelta / 1000);
  if (second > 59) second %= 60;
  if (second < 10) resultTime += '0';
  resultTime += second + ':';

  const mill = Math.floor((timeDelta % 1000) / 10);
  if (mill < 10) resultTime += '0';
  resultTime += mill;

  return resultTime;
};