Update formatTimeLeft logic to be more clean
This commit is contained in:
parent
321549fa88
commit
15c915d1ed
@ -21,11 +21,11 @@ function formatTimeLeft(inputSeconds) {
|
|||||||
const remainingSeconds = seconds % 60;
|
const remainingSeconds = seconds % 60;
|
||||||
|
|
||||||
let result = '';
|
let result = '';
|
||||||
if (years > 0) result += `${years}y `;
|
if (years > 0) result = `over ${years}y`;
|
||||||
if (days > 0) result += `${days}d `;
|
else if (days > 0) result = `over ${days}d`;
|
||||||
if (hours > 0) result += `${hours}h `;
|
else if (hours > 0) result = `${hours}h ${minutes}m`;
|
||||||
if (minutes > 0) result += `${minutes}m `;
|
else if (minutes > 0) result = `${minutes}m ${remainingSeconds}s`;
|
||||||
result += `${remainingSeconds}s`;
|
else result = `${remainingSeconds}s`;
|
||||||
|
|
||||||
return result.trim();
|
return result.trim();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user