fix CustomCalendar
This commit is contained in:
parent
3837e9d3a7
commit
07d748cb0a
@ -40,12 +40,15 @@ function initDay(currentDays = new Array(42), year = defaultYear, month = defaul
|
||||
}
|
||||
|
||||
const days = currentDays;
|
||||
const lastDayOfLastMonth = new Date(year, month, 0);
|
||||
const firstDayOfMonth = new Date(year, month, 1);
|
||||
const lastDayOfMonth = new Date(year, month + 1, 0);
|
||||
const currentDaysOfMonth = lastDayOfMonth.getDate();
|
||||
const daysOfLastMonth = lastDayOfLastMonth.getDate();
|
||||
|
||||
for (let i = 0; i < firstDayOfMonth.getDay(); i++) {
|
||||
days[i] = new Day('', '');
|
||||
const weekDay = firstDayOfMonth.getDay() - 1;
|
||||
days[i] = new Day(year, month - 1, daysOfLastMonth - weekDay + i, week_zh_cn[i]);
|
||||
}
|
||||
|
||||
for (let i = 0; i < currentDaysOfMonth; i++) {
|
||||
|
||||
@ -25,7 +25,8 @@ const editMonth = {
|
||||
|
||||
const handleDayClick = (date) => {
|
||||
year.value = date.month >= 12 ? date.year + 1 : date.year
|
||||
month.value = date.month % 12
|
||||
year.value = date.month < 0 ? date.year - 1 : year.value
|
||||
month.value = date.month < 0 ? 11 : date.month % 12
|
||||
day.value = date.day
|
||||
dayArray.value = initDay(dayArray.value, year.value, month.value, day.value)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user