From c0d712c53deb8e10b391616bd74965642000fbc0 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 3 Jun 2018 20:36:26 +0300 Subject: [PATCH] Remove ability to change date format and timezone --- defaults/config.js | 27 --------------------------- src/helper.js | 6 ++++++ src/log.js | 7 +------ src/plugins/messageStorage/text.js | 7 +------ test/src/helperTest.js | 5 +++++ 5 files changed, 13 insertions(+), 39 deletions(-) diff --git a/defaults/config.js b/defaults/config.js index 0a06b7d4..c8d86bff 100644 --- a/defaults/config.js +++ b/defaults/config.js @@ -161,33 +161,6 @@ module.exports = { // messageStorage: ["sqlite", "text"], - // - // Log settings - // - // Logging has to be enabled per user. If enabled, logs will be stored in - // the 'logs///' folder. - // - // @type object - // @default {} - // - logs: { - // - // Timestamp format - // - // @type string - // @default "YYYY-MM-DD HH:mm:ss" - // - format: "YYYY-MM-DD HH:mm:ss", - - // - // Timezone - // - // @type string - // @default "UTC+00:00" - // - timezone: "UTC+00:00", - }, - // // Maximum number of history lines per channel // diff --git a/src/helper.js b/src/helper.js index a06267a4..388763ea 100644 --- a/src/helper.js +++ b/src/helper.js @@ -8,6 +8,7 @@ const fs = require("fs"); const net = require("net"); const bcrypt = require("bcryptjs"); const colors = require("chalk"); +const moment = require("moment"); let homePath; let configPath; @@ -30,6 +31,7 @@ const Helper = { setHome, getVersion, getGitCommit, + getHumanDate, ip2hex, mergeConfig, getDefaultNick, @@ -205,6 +207,10 @@ function passwordCompare(password, expected) { return bcrypt.compare(password, expected); } +function getHumanDate() { + return moment().format("YYYY-MM-DD HH:mm:ss"); +} + function getDefaultNick() { if (!this.config.defaults.nick) { return "thelounge"; diff --git a/src/log.js b/src/log.js index b627c874..9011623d 100644 --- a/src/log.js +++ b/src/log.js @@ -1,16 +1,11 @@ "use strict"; const colors = require("chalk"); -const moment = require("moment"); const read = require("read"); const Helper = require("./helper"); function timestamp() { - const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss"; - const tz = Helper.config.logs.timezone || "UTC+00:00"; - const time = moment().utcOffset(tz).format(format); - - return colors.dim(time); + return colors.dim(Helper.getHumanDate()); } module.exports = { diff --git a/src/plugins/messageStorage/text.js b/src/plugins/messageStorage/text.js index 0b7d436b..d979e5cb 100644 --- a/src/plugins/messageStorage/text.js +++ b/src/plugins/messageStorage/text.js @@ -3,7 +3,6 @@ const fs = require("fs"); const fsextra = require("fs-extra"); const path = require("path"); -const moment = require("moment"); const filenamify = require("filenamify"); const Helper = require("../../helper"); @@ -40,11 +39,7 @@ class TextFileMessageStorage { return; } - const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss"; - const tz = Helper.config.logs.timezone || "UTC+00:00"; - - const time = moment(msg.time).utcOffset(tz).format(format); - let line = `[${time}] `; + let line = `[${Helper.getHumanDate()}] `; if (msg.type === "message") { // Format: diff --git a/test/src/helperTest.js b/test/src/helperTest.js index e7cd33c1..54ae3264 100644 --- a/test/src/helperTest.js +++ b/test/src/helperTest.js @@ -2,6 +2,7 @@ const expect = require("chai").expect; const os = require("os"); +const moment = require("moment"); const Helper = require("../../src/helper"); describe("Helper", function() { @@ -52,4 +53,8 @@ describe("Helper", function() { expect(version).to.match(/v[0-9]+\.[0-9]+\.[0-9]+/); }); }); + + describe("#getHumanDate()", function() { + expect(Helper.getHumanDate()).to.equal(moment().format("YYYY-MM-DD HH:mm:ss")); + }); });