fix(Util): fix time code builder

This commit is contained in:
DevAndromeda 2021-08-07 22:56:00 +05:45
parent bce34c9fc8
commit 2575e2ab72
No known key found for this signature in database
GPG key ID: FA40E3EC5CB6DCD6

View file

@ -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;
}