feat: future day grey.

This commit is contained in:
2025-11-11 14:42:42 +08:00
parent 9b1eb6cafd
commit d4765a5baf
2 changed files with 24 additions and 0 deletions

View File

@@ -123,6 +123,11 @@ export default class CalendarView {
dayEl.classList.add('other-month');
}
// Check if the day is in the future
if (this.isFutureDate(date)) {
dayEl.classList.add('future-day');
}
if (this.isToday(date)) {
dayEl.classList.add('today');
}
@@ -235,6 +240,15 @@ export default class CalendarView {
date.getDate() === today.getDate();
}
// Check if a date is in the future
isFutureDate(date) {
const today = new Date();
today.setHours(0, 0, 0, 0);
const checkDate = new Date(date);
checkDate.setHours(0, 0, 0, 0);
return checkDate > today;
}
formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');