mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-09 01:04:16 +02:00
move isLeap to Util
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user