カレンダーの元データはこちらから取得しました。
https://github.com/MathiasWP/CalendarPickerJS/
date.getDay()
の部分で以下のエラーが出ます。
特定の曜日の時にあるCSSを適応させたいです。
エラーメッセージ:
Uncaught TypeError: date.getDay is not a function
at CalendarPicker.js:278
at Array.forEach (<anonymous>)
at CalendarPicker._insertDaysIntoGrid (Ca.js:263)
at new CalendarPicker (Ca.js:96)
at a:137
(anonymous) @ a:278
CalendarPicker._insertDaysIntoGrid @:263
CalendarPicker a
(anonymous) @ a:137
ソースコード:
CalendarPicker.prototype._insertDaysIntoGrid = function () {
this.calendarGrid.innerHTML = '';
var arrayOfDays = this._getDaysInMonth(this.month, this.year);
var firstDayOfMonth = arrayOfDays[0].getDay();
// Converting Sunday (0 when using getDay()) to 7 to make it easier to work with.
firstDayOfMonth = firstDayOfMonth === 0 ? 7 : firstDayOfMonth;
if (1 < firstDayOfMonth) {
arrayOfDays = Array(firstDayOfMonth - 1).fill(false, 0).concat(arrayOfDays);
}
arrayOfDays.forEach(date => {
var dateElement = document.createElement(date ? this.calendarDayElementType : 'span');
var Date = date.toString().split(' ')[2];
var dateIsTheCurrentValue = this.value.toString() === date.toString();
if (dateIsTheCurrentValue) this.activeDateElement = dateElement;
var dateIsBetweenAllowedRange = (this.min || this.max) && (date.toString() !== this.today.toString() && (date < this.min || date > this.max))
if (dateIsBetweenAllowedRange) {
dateElement.classList.add('disabled');
} else {
dateElement.tabIndex = 0;
dateElement.value = date;
}
if(date.getDay() == 5)
{
dateElement.classList.add('friday');
}
dateElement.textContent = date ? Date : '';
this.calendarGrid.appendChild(dateElement);
})