From ad9bb1e453717ab116dba3bee64160cd88052ee6 Mon Sep 17 00:00:00 2001 From: DCoded <dsoloha@live.com> Date: Tue, 28 May 2019 00:38:23 -0400 Subject: [PATCH] Time() fixes --- src/js/utilJS.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/js/utilJS.js b/src/js/utilJS.js index 8b407ce87a9..d0b7af867cc 100644 --- a/src/js/utilJS.js +++ b/src/js/utilJS.js @@ -1113,12 +1113,20 @@ window.time = function(weeks) { if (weeks >= 52) { // at least one year r += `${num(Math.trunc(weeks / 52))} year${Math.trunc(weeks / 52) != 1 ? `s` : ``}`; - if (Math.trunc(weeks - 52) % 4 !== 0) { // more than x years, y months - r += `, `; - } else if (Math.trunc(weeks / 52) > 0) { // more than one year + if ((weeks - 52) % 4 !== 0) { // more than x years, y months + if (Math.trunc(weeks - 52) % 4 > 3) { + r += `, `; + } else { + r += ` and `; + } + } else if (Math.trunc(weeks / 52) > 1) { // more than one year if ((weeks / 52) % 2 !== 0) { // not exactly x years r += ` and `; } + } else if ((weeks - 52) % 4 === 0) { + if (weeks % 52 !== 0) { + r += ` and `; + } } weeks -= Math.trunc(weeks / 52) * 52; // rounds down to and drops number of years } -- GitLab