myrta-ui 1.1.96 → 1.1.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fesm2020/myrta-ui.mjs
CHANGED
|
@@ -9477,21 +9477,28 @@ class DateCalendarComponent {
|
|
|
9477
9477
|
if (this.calendarDaysCache?.month === this.currentMonth && this.calendarDaysCache?.year === this.currentYear) {
|
|
9478
9478
|
return this.calendarDaysCache.days;
|
|
9479
9479
|
}
|
|
9480
|
+
// Определяем количество дней в текущем, предыдущем и следующем месяцах
|
|
9480
9481
|
const daysInMonth = new Date(this.currentYear, this.currentMonth + 1, 0).getDate();
|
|
9481
9482
|
const prevMonthDays = new Date(this.currentYear, this.currentMonth, 0).getDate();
|
|
9482
9483
|
const days = [];
|
|
9483
|
-
|
|
9484
|
+
// Вычисляем, сколько дней взять из предыдущего месяца, чтобы неделя начиналась с понедельника
|
|
9485
|
+
const firstDayJS = new Date(this.currentYear, this.currentMonth, 1).getDay(); // 0 = воскресенье, 1 = понедельник, ...
|
|
9486
|
+
const prevDaysCount = (firstDayJS + 6) % 7; // 0..6, где 0 означает, что 1-е число уже понедельник
|
|
9484
9487
|
const prevMonth = this.currentMonth === 0 ? 11 : this.currentMonth - 1;
|
|
9485
9488
|
const prevYear = this.currentMonth === 0 ? this.currentYear - 1 : this.currentYear;
|
|
9486
9489
|
const nextMonth = this.currentMonth === 11 ? 0 : this.currentMonth + 1;
|
|
9487
9490
|
const nextYear = this.currentMonth === 11 ? this.currentYear + 1 : this.currentYear;
|
|
9491
|
+
// Предыдущие дни (если нужны)
|
|
9488
9492
|
for (let i = 0; i < prevDaysCount; i++) {
|
|
9489
9493
|
days.push({ day: prevMonthDays - prevDaysCount + 1 + i, month: prevMonth, year: prevYear });
|
|
9490
9494
|
}
|
|
9495
|
+
// Дни текущего месяца
|
|
9491
9496
|
for (let i = 1; i <= daysInMonth; i++) {
|
|
9492
9497
|
days.push({ day: i, month: this.currentMonth, year: this.currentYear });
|
|
9493
9498
|
}
|
|
9494
|
-
|
|
9499
|
+
// Дозаполняем до полного количества ячеек (6 недель по 7 дней = 42)
|
|
9500
|
+
const totalCells = 42;
|
|
9501
|
+
const remainingDays = totalCells - days.length;
|
|
9495
9502
|
for (let i = 1; i <= remainingDays; i++) {
|
|
9496
9503
|
days.push({ day: i, month: nextMonth, year: nextYear });
|
|
9497
9504
|
}
|