public void SetsTheMonthTo12IfMonthIs1(PositiveInt positiveInt) { var year = positiveInt.Get; var calendarMonth = new CalendarMonth(year, 1); var nextCalendarMonth = calendarMonth.Previous(); nextCalendarMonth.Month.Should().Be(12); }
public void DecreasesTheYearIfMonthIs1(PositiveInt positiveInt) { var year = positiveInt.Get; var calendarMonth = new CalendarMonth(year, 1); var nextCalendarMonth = calendarMonth.Previous(); nextCalendarMonth.Year.Should().Be(year - 1); }
public void DecrementsTheMonthIfMonthIsGreaterThan1(int month) { if (month == 1) { return; } var calendarMonth = new CalendarMonth(1234, month); var previousCalendarMonth = calendarMonth.Previous(); previousCalendarMonth.Month.Should().Be(month - 1); }
public void DoesNotDecrementTheYearWhenMonthIsGreaterThan1(int month) { if (month == 1) { return; } var year = 2020; var calendarMonth = new CalendarMonth(year, month); var nextCalendarMonth = calendarMonth.Previous(); nextCalendarMonth.Year.Should().Be(year); }
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); } }