From da66f518a08d07085dc30b1e7d2e58cdf2a50355 Mon Sep 17 00:00:00 2001 From: object Date: Sat, 13 Aug 2022 19:29:58 +0000 Subject: [PATCH] New util for monsterplants --- src/api/utils/ConvertSeconds.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/api/utils/ConvertSeconds.ts diff --git a/src/api/utils/ConvertSeconds.ts b/src/api/utils/ConvertSeconds.ts new file mode 100644 index 00000000..f559dea9 --- /dev/null +++ b/src/api/utils/ConvertSeconds.ts @@ -0,0 +1,9 @@ +export const ConvertSeconds = (seconds: number) => +{ + let numDays = Math.floor(seconds / 86400); + let numHours = Math.floor((seconds % 86400) / 3600); + let numMinutes = Math.floor(((seconds % 86400) % 3600) / 60); + let numSeconds = ((seconds % 86400) % 3600) % 60; + + return numDays.toString().padStart(2, '0') + ':' + numHours.toString().padStart(2, '0') + ':' + numMinutes.toString().padStart(2, '0') + ':' + numSeconds.toString().padStart(2, '0'); +}