diff --git a/commands/events/calendar.js b/commands/events/calendar.js index 7a273b6a..a5a1ffca 100644 --- a/commands/events/calendar.js +++ b/commands/events/calendar.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const { stripIndents } = require('common-tags'); -const { firstUpperCase } = require('../../util/Util'); +const { firstUpperCase, isLeap } = require('../../util/Util'); const monthsWith30 = [4, 6, 9, 11]; const months = require('../../assets/json/month'); @@ -42,7 +42,7 @@ module.exports = class CalendarCommand extends Command { for (let i = 0; i < startDay; i++) { display += ' '; } - const daysInMonth = month === 2 ? this.isLeap(year) ? 29 : 28 : monthsWith30.includes(month) ? 30 : 31; + const daysInMonth = month === 2 ? isLeap(year) ? 29 : 28 : monthsWith30.includes(month) ? 30 : 31; let currentDay = startDay; for (let i = 0; i < daysInMonth; i++) { display += `| ${(i + 1).toString().padStart(2, '0')} `; @@ -56,8 +56,4 @@ module.exports = class CalendarCommand extends Command { display += '|'; return msg.code(null, display); } - - isLeap(year) { - return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); - } }; diff --git a/util/Util.js b/util/Util.js index 08169584..be4997a7 100644 --- a/util/Util.js +++ b/util/Util.js @@ -169,6 +169,10 @@ module.exports = class Util { return today; } + static isLeap(year) { + return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); + } + static magikToBuffer(magik) { return new Promise((res, rej) => { magik.toBuffer((err, buffer) => {