Better Date Format

This commit is contained in:
Dragon Fire
2020-12-02 09:53:33 -05:00
parent 5911de8d21
commit 8517a473e6
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ module.exports = class CalendarCommand extends Command {
------------------------------------
`;
display += '\n';
const startDay = new Date(`${month}/1/${year}`).getDay();
const startDay = new Date(year, month - 1, 1).getDay();
for (let i = 0; i < startDay; i++) {
display += ' ';
}
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class DaysSinceCommand extends Command {
run(msg, { month, day, year }) {
const now = new Date();
const past = new Date(`${month}/${day}/${year}`);
const past = new Date(year, month - 1, day);
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}!`);
+1 -1
View File
@@ -31,7 +31,7 @@ module.exports = class DaysUntilCommand extends Command {
const now = new Date();
let year = now.getMonth() + 1 <= month ? now.getFullYear() : now.getFullYear() + 1;
if (month === now.getMonth() + 1 && now.getDate() >= day) ++year;
const future = new Date(`${month}/${day}/${year}`);
const future = new Date(year, month - 1, day);
const futureFormat = moment.utc(future).format('dddd, MMMM Do, YYYY');
const time = moment.duration(future - now);
const link = time.months() ? time.months() === 1 ? 'is' : 'are' : time.days() === 1 ? 'is' : 'are';