mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-08 15:19:14 +02:00
Better Date Format
This commit is contained in:
@@ -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 += ' ';
|
||||
}
|
||||
|
||||
@@ -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}!`);
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user