thaldrin/utils/src/calc.js

21 lines
533 B
JavaScript
Raw Normal View History

2019-10-14 11:19:41 +00:00
module.exports = {
userDays: function(user) {
if (typeof user !== "object") throw new TypeError("Not an Object");
let creation = new Date().getTime() - user.createdAt.getTime();
let days = creation / 1000 / 60 / 60 / 24;
return Math.round(days);
},
serverDays: function(server) {
if (typeof user !== "object") throw new TypeError("Not an Object");
let creation = new Date().getTime() - server.createdAt.getTime();
let days = creation / 1000 / 60 / 60 / 24;
return Math.round(days);
}
};