Fixed bug in populate days where day 2 was beimg skipped for each month.

This commit is contained in:
Lucid Kobold
2021-12-08 17:55:43 -06:00
parent 0d69dc7d08
commit 99103a8719

View File

@@ -43,23 +43,19 @@ const CalenderContextProvider = ({
getDate(endOfMonth(selectedDate))
);
const [daysOfMonth, setDaysOfMonth] = useState<[number]>([0]);
const [daysOfMonth, setDaysOfMonth] = useState<[number]>([1]);
// Update or populate the days of the month.
const populateDays = (): void => {
let newDaysOfMonth: [number] = [...daysOfMonth];
if (newDaysOfMonth.length > 1) {
newDaysOfMonth = [0];
newDaysOfMonth = [1];
}
for (let i = 1; i < endOfSelectedMonth; i++) {
if (newDaysOfMonth[i - 1] === 0) {
newDaysOfMonth[i - 1] = i;
} else {
newDaysOfMonth.push(i + 1);
}
}
setDaysOfMonth(newDaysOfMonth);
};