private void addDaysFromNextMonth() { var lastDayOfWeekInTargetMonth = (int)CalendarMonth .DayOfWeek(CalendarMonth.DaysInMonth); var nextMonth = CalendarMonth.AddMonths(1); var lastDayOfWeek = ((int)beginningOfWeek + 6) % 7; var daysToAdd = (lastDayOfWeek - lastDayOfWeekInTargetMonth + 7) % 7; for (int i = 0; i < daysToAdd; i++) { addDay(i + 1, nextMonth, false); } }
private void addDaysFromPreviousMonth() { var firstDayOfMonth = CalendarMonth.DayOfWeek(1); if (firstDayOfMonth == beginningOfWeek.ToDayOfWeekEnum()) { return; } var previousMonth = CalendarMonth.Previous(); var daysInPreviousMonth = previousMonth.DaysInMonth; var daysToAdd = ((int)firstDayOfMonth - (int)beginningOfWeek.ToDayOfWeekEnum() + 7) % 7; for (int i = daysToAdd - 1; i >= 0; i--) { addDay(daysInPreviousMonth - i, previousMonth, false); } }