Skip to content

Commit

Permalink
feat: add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kostasdano committed Sep 20, 2023
1 parent ebcc185 commit e941f26
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/DatePicker/Month/Month.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const Month: React.FC<Props> = ({ year, month, onDaySelect, selectedDays, disabl
const weeksWithDays = React.useMemo<WeekRow[]>(() => {
const monthDate = currentDay.month(month).year(year).date(1);
const daysOfMonth = monthDate.daysInMonth();
const startDay = monthDate.day() ? monthDate.day() : 7;
/**
* Dayjs uses 0-6 (Sun-Sat) indexing for days of the week, while the reduce callback on line 48 uses
* 1-7 (Mon-Sun) indexing for calculating the days array for the calendar grid. To resolve this conflict,
* we replace the 0 used for Sunday with 7, so that Dayjs can match our internal indexing.
*/
const startDay = monthDate.day() || 7;
const daysPerWeekCount = 7;
const weeksCount = getNumWeeksForMonth(year, month);
const daysForThisMonthsWeeks = Array(weeksCount * daysPerWeekCount).fill(null);
Expand Down

0 comments on commit e941f26

Please sign in to comment.