From 2575e2ab724771817ab003356878439a01373d80 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Sat, 7 Aug 2021 22:56:00 +0545 Subject: [PATCH] fix(Util): fix time code builder --- src/utils/Util.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 8b2c6d8..18f8e80 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -43,11 +43,12 @@ class Util { const items = Object.keys(duration); const required = ["days", "hours", "minutes", "seconds"]; - const parsed = items.filter((x) => required.includes(x)).map((m) => (duration[m as keyof TimeData] > 0 ? duration[m as keyof TimeData] : "")); + const parsed = items.filter((x) => required.includes(x)).map((m) => duration[m as keyof TimeData]); const final = parsed - .filter((x) => !!x) + .slice(parsed.findIndex((x) => x !== 0)) .map((x) => x.toString().padStart(2, "0")) .join(":"); + return final.length <= 3 ? `0:${final.padStart(2, "0") || 0}` : final; }