Support Years from 1 - 99

This commit is contained in:
Dragon Fire
2020-12-02 09:55:54 -05:00
parent 8517a473e6
commit 9621fae3b0
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -22,7 +22,7 @@ module.exports = class CalendarCommand extends Command {
key: 'year',
prompt: 'What year would you like to get the calendar of?',
type: 'integer',
min: 100
min: 1
}
]
});
@@ -37,6 +37,7 @@ module.exports = class CalendarCommand extends Command {
`;
display += '\n';
const startDay = new Date(year, month - 1, 1).getDay();
if (year > 100) startDay.setFullYear(year);
for (let i = 0; i < startDay; i++) {
display += ' ';
}
+2 -1
View File
@@ -26,7 +26,7 @@ module.exports = class DaysSinceCommand extends Command {
key: 'year',
prompt: 'What year would you like to get the days since?',
type: 'integer',
min: 100
min: 1
}
]
});
@@ -35,6 +35,7 @@ module.exports = class DaysSinceCommand extends Command {
run(msg, { month, day, year }) {
const now = new Date();
const past = new Date(year, month - 1, day);
if (year > 100) past.setFullYear(year);
const pastFormat = moment.utc(past).format('dddd, MMMM Do, YYYY');
const time = moment.duration(now - past);
return msg.say(`There have been ${time.format('Y [years,] M [months and] d [days]')} since ${pastFormat}!`);