diff --git a/modules/consoleHelper.js b/modules/consoleHelper.js index 1a8ddcf..c0f2c48 100644 --- a/modules/consoleHelper.js +++ b/modules/consoleHelper.js @@ -13,6 +13,7 @@ if (!fs.existsSync(__dirname + BASE_PATH)) { fs.mkdirSync(__dirname + BASE_PATH); console.log(`[consoleHelper] Made consoleHelper module folder`); } +// Creates the consoleHelper config file if (!fs.existsSync(__dirname + BASE_PATH + "/config.json")) { fs.writeFileSync(__dirname + BASE_PATH + "/config.json", JSON.stringify({"24hour":true})); console.log(`[consoleHelper] Made consoleHelper config file`); @@ -35,20 +36,26 @@ module.exports = { getTime24:function() { const time = new Date(); + // Check if the user wants 24 hour or 12 hour time if (config["24hour"]) { + // User wants 24 hour time, leave it as it is. return `${correctValue(time.getHours())}:${correctValue(time.getMinutes())}:${correctValue(time.getSeconds())}`; } else { + // User wants 12 hour time, process it for that. return this.t2412(`${correctValue(time.getHours())}:${correctValue(time.getMinutes())}:${correctValue(time.getSeconds())}`); } }, t2412:function(inp) { + // Check what time it is, AM or PM. if (parseInt(inp.split(":")[0]) > 11) { + // It's over 11 so it's PM const i = inp.split(":"); let i1 = parseInt(i[0]) - 12; if (i1 == 0) i1 = 12; return i1 + ":" + i[1] + " PM"; } else { + // It's lower than 12 so it's AM const i = inp.split(":"); let i1 = parseInt(i[0]); if (i1 == 0) i1 = 12; @@ -59,6 +66,7 @@ module.exports = { module.exports.MOD_FUNC = MODULE_FUNCTION; +// Date returns numbers without a 0 in front of them of course so this adds them. function correctValue(i) { if (i < 10) { return "0"+i;