more date fixes

This commit is contained in:
2024-08-27 20:16:33 -06:00
parent 27349af5b9
commit 72f391dcf9
4 changed files with 22 additions and 39 deletions

View File

@@ -5,27 +5,23 @@ import { getMonthsBetweenDates } from "./calendarMonthUtils";
import { CalendarMonth } from "./CalendarMonth";
export default function CourseCalendar() {
const context = useCourseContext();
const {
localCourse: {
settings: { startDate, endDate },
},
} = useCourseContext();
const startDate = getDateFromStringOrThrow(
context.localCourse.settings.startDate,
const startDateTime = getDateFromStringOrThrow(
startDate,
"course start date"
);
const endDate = getDateFromStringOrThrow(
context.localCourse.settings.endDate,
"course end date"
);
const months = getMonthsBetweenDates(startDate, endDate);
const endDateTime = getDateFromStringOrThrow(endDate, "course end date");
const months = getMonthsBetweenDates(startDateTime, endDateTime);
return (
<>
{months.map((month) => (
<CalendarMonth
key={month.month + "" + month.year}
month={month}
localCourse={context.localCourse}
/>
<CalendarMonth key={month.month + "" + month.year} month={month} />
))}
</>
);