mirror of
https://github.com/thelounge/thelounge
synced 2024-11-10 14:44:13 +00:00
refactor getHumanDate() to accept a timestamp; fixes test
This commit is contained in:
parent
5b2de64af8
commit
9bee3eca5a
3 changed files with 4 additions and 4 deletions
|
@ -32,7 +32,7 @@ module.exports = {
|
|||
read(options, callback);
|
||||
},
|
||||
|
||||
getHumanDate() {
|
||||
return moment().format("YYYY-MM-DD HH:mm:ss");
|
||||
getHumanDate(ts) {
|
||||
return moment(ts).format("YYYY-MM-DD HH:mm:ss");
|
||||
},
|
||||
};
|
||||
|
|
|
@ -41,7 +41,7 @@ class TextFileMessageStorage {
|
|||
return;
|
||||
}
|
||||
|
||||
let line = `[${log.getHumanDate()}] `;
|
||||
let line = `[${log.getHumanDate(msg.time)}] `;
|
||||
|
||||
// message types from src/models/msg.js
|
||||
switch (msg.type) {
|
||||
|
|
|
@ -56,6 +56,6 @@ describe("Helper", function() {
|
|||
});
|
||||
|
||||
describe("#getHumanDate()", function() {
|
||||
expect(log.getHumanDate()).to.equal(moment().format("YYYY-MM-DD HH:mm:ss"));
|
||||
expect(log.getHumanDate(moment(1455090480000).utc())).to.equal("2016-02-10 07:48:00");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue