can select course from existing file

This commit is contained in:
2023-07-24 13:39:22 -06:00
parent 04274bd6c5
commit 6232a7a94e
17 changed files with 168 additions and 118 deletions

View File

@@ -2,28 +2,20 @@ using CanvasModel.EnrollmentTerms;
public class SemesterPlanner
{
public DateTime FirstDay { get; }
public DateTime LastDay { get; }
public IEnumerable<CalendarMonth> Months { get; }
public IEnumerable<DayOfWeek> Days { get; }
public SemesterPlanner(SemesterCalendarConfig configuration)
public static IEnumerable<CalendarMonth> GetMonthsBetweenDates(
DateTime startDate,
DateTime endDate
)
{
FirstDay = configuration.StartDate;
LastDay = configuration.EndDate;
var monthsInTerm = 1 + ((endDate.Year - startDate.Year) * 12) + endDate.Month - startDate.Month;
var monthsInTerm =
1 + ((LastDay.Year - FirstDay.Year) * 12)
+ LastDay.Month - FirstDay.Month;
Months = Enumerable
return Enumerable
.Range(0, monthsInTerm)
.Select(monthDiff =>
{
var month = ((FirstDay.Month + monthDiff - 1) % 12) + 1;
var year = FirstDay.Year + ((FirstDay.Month + monthDiff - 1) / 12);
var month = ((startDate.Month + monthDiff - 1) % 12) + 1;
var year = startDate.Year + ((startDate.Month + monthDiff - 1) / 12);
return new CalendarMonth(year, month);
});
Days = configuration.Days;
}
}
}