fix bug with calendar offset

This commit is contained in:
marlon-erler
2024-09-07 11:30:43 -07:00
parent eef43f5077
commit 93f4cee957
3 changed files with 19 additions and 4 deletions
+11 -3
View File
@@ -64,14 +64,22 @@ export default class CalendarModel {
const isCurrentMonth: boolean =
year == date.getFullYear() && month == date.getMonth() + 1;
// get first day of month
// get data for offset
date.setFullYear(year);
date.setMonth(month - 1);
date.setDate(1);
// get offset
const firstWeekdayOfMonth = date.getDay();
const firstDayOfWeekSetting: number = parseInt(
this.settingsModel.firstDayOfWeek
);
console.log(firstWeekdayOfMonth, firstDayOfWeekSetting);
const offset: number =
date.getDay() - parseInt(this.settingsModel.firstDayOfWeek);
firstWeekdayOfMonth == 0
? 7 - firstDayOfWeekSetting
: firstWeekdayOfMonth - firstDayOfWeekSetting;
// get total day count
date.setMonth(month);
+1
View File
@@ -25,6 +25,7 @@ export function MonthGrid<T>(
}
const offsetElements: HTMLElement[] = [];
console.log(monthGrid.offset);
for (let i = 0; i < monthGrid.offset; i++) {
offsetElements.push(<div></div>);
}