Improve date handling in CalendarView: Add comments to clarify the logic for setting the date to the first of the month to prevent overflow issues when navigating between months. This enhancement aids in maintaining accurate date transitions in the calendar view.

This commit is contained in:
Torsten Schulz (local)
2026-01-30 14:41:02 +01:00
parent 786420d1d2
commit ec75c7ecdb

View File

@@ -467,6 +467,8 @@ export default {
const newDate = new Date(this.currentDate);
switch (this.currentView) {
case 'month':
// Set day to 1 first to avoid month overflow (e.g., Jan 31 - 1 month = Dec 31, not Dec 1)
newDate.setDate(1);
newDate.setMonth(newDate.getMonth() - 1);
break;
case 'week':
@@ -483,6 +485,8 @@ export default {
const newDate = new Date(this.currentDate);
switch (this.currentView) {
case 'month':
// Set day to 1 first to avoid month overflow (e.g., Jan 30 + 1 month would skip Feb)
newDate.setDate(1);
newDate.setMonth(newDate.getMonth() + 1);
break;
case 'week':