Fixed small bug

This commit is contained in:
Daniël van Noord
2021-04-12 21:19:07 +02:00
parent f5e342f7c5
commit 84eed2d7c4
4 changed files with 10 additions and 10 deletions

View File

@@ -11,11 +11,11 @@ export default function FormatTime(time, longFormat) {
if (time === Infinity) return time;
if (time < 0) return 'Negative time period';
formattedTime = Math.ceil(time);
const y = Math.floor(formattedTime / 31557600);
const d = Math.floor((formattedTime % 31557600) / 86400);
const h = Math.floor((formattedTime % 86400) / 3600);
const m = Math.floor((formattedTime % 3600) / 60);
const s = Math.floor(formattedTime % 60);
const y = Math.floor(formattedTime / 31536000);
const d = Math.floor((formattedTime % 31536000) / 86400);
const h = Math.floor(((formattedTime % 31536000) % 86400) / 3600);
const m = Math.floor((((formattedTime % 31536000) % 86400) % 3600) / 60);
const s = Math.floor((((formattedTime % 31536000) % 86400) % 3600) % 60);
let str = '';
if (CMOptions.TimeFormat) {
if (formattedTime > 3155760000) return 'XX:XX:XX:XX:XX';
@@ -31,8 +31,8 @@ export default function FormatTime(time, longFormat) {
y > 0
? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, ` // eslint-disable-line no-nested-ternary
: '';
str +=
d > 0 ? `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, ` : ''; // eslint-disable-line no-nested-ternary
if (str.length > 0 || d > 0)
str += `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, `; // eslint-disable-line no-nested-ternary
if (str.length > 0 || h > 0)
str += `${h + (longFormat ? (h === 1 ? ' hour' : ' hours') : 'h')}, `; // eslint-disable-line no-nested-ternary
if (str.length > 0 || m > 0)