aboutsummaryrefslogtreecommitdiff
path: root/src/utils/convertTimeToString.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/convertTimeToString.ts')
-rw-r--r--src/utils/convertTimeToString.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils/convertTimeToString.ts b/src/utils/convertTimeToString.ts
new file mode 100644
index 0000000..098f34a
--- /dev/null
+++ b/src/utils/convertTimeToString.ts
@@ -0,0 +1,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;
+};