mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
better class day highlighting
This commit is contained in:
@@ -2,23 +2,26 @@ 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(SemesterConfiguration configuration)
|
||||
{
|
||||
var start = configuration.StartDate;
|
||||
var end = configuration.EndDate;
|
||||
FirstDay = configuration.StartDate;
|
||||
LastDay = configuration.EndDate;
|
||||
|
||||
var monthsInTerm =
|
||||
1 + ((end.Year - start.Year) * 12)
|
||||
+ end.Month - start.Month;
|
||||
1 + ((LastDay.Year - FirstDay.Year) * 12)
|
||||
+ LastDay.Month - FirstDay.Month;
|
||||
|
||||
Months = Enumerable
|
||||
.Range(0, monthsInTerm)
|
||||
.Select(monthDiff =>
|
||||
{
|
||||
var month = ((start.Month + monthDiff - 1) % 12) + 1;
|
||||
var year = start.Year + ((start.Month + monthDiff - 1) / 12);
|
||||
var month = ((FirstDay.Month + monthDiff - 1) % 12) + 1;
|
||||
var year = FirstDay.Year + ((FirstDay.Month + monthDiff - 1) / 12);
|
||||
return new CalendarMonth(year, month);
|
||||
});
|
||||
Days = configuration.Days;
|
||||
|
||||
Reference in New Issue
Block a user