From 01a6bf663b46df75694432145e9ca4d45daca66b Mon Sep 17 00:00:00 2001
From: DCoded <dsoloha@live.com>
Date: Tue, 28 May 2019 23:13:29 -0400
Subject: [PATCH] Removed JSdoc from ESlint, minor time() tweaks

---
 .eslintrc.json   |  3 ---
 src/js/utilJS.js | 36 +++++++++++++++++++++++-------------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/.eslintrc.json b/.eslintrc.json
index 23d7a4227ab..cfd661246ec 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -27,9 +27,6 @@
 			"impliedStrict": true
 		}
 	},
-	"plugins": [
-		"jsdoc"
-	],
 	"rules": {
 		"semi": ["warn", "always"],
 		"semi-spacing": "warn",
diff --git a/src/js/utilJS.js b/src/js/utilJS.js
index 5f0ad823a11..c80b279000f 100644
--- a/src/js/utilJS.js
+++ b/src/js/utilJS.js
@@ -1108,35 +1108,45 @@ window.num = function(x) {
  * @returns {string}
  */
 window.time = function(weeks) {
-	let	r = ``;
+	let
+		r = ``,
+		years,
+		months;
 
-	if (weeks >= 52) {								// at least one year
-		r += `${num(Math.trunc(weeks / 52))} year${Math.trunc(weeks / 52) != 1 ? `s` : ``}`;
+	if (weeks >= 52) {							// at least one year
+		years = Math.trunc(weeks / 52);
 
-		if ((weeks - 52) % 4 !== 0) {				// not exactly x years, y months
+		r += `${num(years)} year${years !== 1 ? `s` : ``}`;
+
+		if ((weeks - 52) % 4.33 !== 0) {		// not exactly x years, y months
 				r += `, `;
 		} else {
-			if (weeks % 52 !== 0) {					// not exactly x years
+			if (weeks % 52 !== 0) {				// not exactly x years
 				r += ` and `;
 			}
 		}
-		weeks -= Math.trunc(weeks / 52) * 52;		// rounds down to and drops number of years
+		weeks -= years * 52;					// rounds down to and drops number of years
 	}
 
-	if (weeks >= 4) {								// at least one month
-		r += `${num(Math.trunc(weeks / 4))} month${Math.trunc(weeks / 4) != 1 ? `s` : ``}`;
-		weeks -= Math.trunc(weeks / 4) * 4;			// rounds down to and drops number of months
-		if (weeks > 0) {
+	if (weeks >= 4.33) {						// at least one month
+		months = Math.trunc(weeks / 4.33);
+
+		r += `${num(months)} month${months !== 1 ? `s` : ``}`;
+
+		weeks -= months * 4.33;					// rounds down to and drops number of months
+		if (weeks >= 1) {
 			r += ` and `;
 		}
 	}
 
-	if (weeks > 0) {
-		r += `${num(weeks)} week${weeks != 1 ? `s` : ``}`;
+	if (weeks >= 1) {
+		weeks = Math.trunc(weeks);
+
+		r += `${num(weeks)} week${weeks !== 1 ? `s` : ``}`;
 	}
 
 	return r;
-}
+};
 
 /**
  * @param {number} s
-- 
GitLab