コード例 #1
0
            public void SetsTheMonthTo12IfMonthIs1(PositiveInt positiveInt)
            {
                var year          = positiveInt.Get;
                var calendarMonth = new CalendarMonth(year, 1);

                var nextCalendarMonth = calendarMonth.Previous();

                nextCalendarMonth.Month.Should().Be(12);
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            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);
            }
コード例 #4
0
            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);
            }
コード例 #5
0
        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);
            }
        }