private DateTime GetYesterday()
 {
     TimeSpan spanToSubtract = new TimeSpan(1, 0, 0, 0);
     DateTime dateResult = DateTime.MinValue;
     if (DateSubtractWontBeLessThanMinDate(referenceDate, spanToSubtract))
     {
         dateResult = new DateTime(referenceDate.Year, referenceDate.Month, referenceDate.Day, 0, 0, 0);
         dateResult = dateResult.Subtract(spanToSubtract);
     }
     else
     {
         FrequencyError newError = new FrequencyError(FrequencyErrorTypes.ResultLessThanDateMin);
         errors.Add(newError);
     }
     return dateResult;
 }
 private DateTime GetTomorrow()
 {
     TimeSpan spanToAdd = new TimeSpan(1, 0, 0, 0);
     DateTime dateResult = DateTime.MaxValue;
     if (DateAddWontExceedMaxDate(referenceDate, spanToAdd))
     {
         dateResult = new DateTime(referenceDate.Year, referenceDate.Month, referenceDate.Day, 0, 0, 0);
         dateResult = dateResult.Add(spanToAdd);
     }
     else
     {
         FrequencyError newError = new FrequencyError(FrequencyErrorTypes.ResultGreaterThanDateMax);
         errors.Add(newError);
     }
     return dateResult;
 }
 private DateTime GetNextYear()
 {
     DateTime resultDate = DateTime.MaxValue;
     if (YearNotGreaterThanMaximumYear(referenceDate.Year + 1))
     {
         resultDate = new DateTime(referenceDate.Year + 1, 1, 1, 0, 0, 0);
     }
     else
     {
         FrequencyError newError = new FrequencyError(FrequencyErrorTypes.ResultGreaterThanDateMax);
         errors.Add(newError);
     }
     return resultDate;
 }
 private DateTime GetNextMonth()
 {
     DateTime resultDate = DateTime.MaxValue;
     if ((referenceDate.Month != 12) || (YearNotGreaterThanMaximumYear(referenceDate.Year + 1)))
     {
         DateTime nextMonth = GetThisMonth();
         nextMonth = nextMonth.Add(new TimeSpan(27, 0, 0, 0));
         int monthOfPriorDate = nextMonth.Month;
         int monthOfCurrentDate = monthOfPriorDate;
         while (monthOfCurrentDate == monthOfPriorDate)
         {
             nextMonth = nextMonth.Add(new TimeSpan(1, 0, 0, 0));
             monthOfCurrentDate = nextMonth.Month;
         }
         resultDate = new DateTime(nextMonth.Year, nextMonth.Month, nextMonth.Day, 0, 0, 0);
     }
     else
     {
         FrequencyError newError = new FrequencyError(FrequencyErrorTypes.ResultGreaterThanDateMax);
         errors.Add(newError);
     }
     return resultDate;
 }
 private DateTime GetLastYear()
 {
     DateTime resultDate = DateTime.MinValue;
     if (YearNotLessThanMinimumYear(referenceDate.Year - 1))
     {
         resultDate = new DateTime(referenceDate.Year - 1, 1, 1, 0, 0, 0);
     }
     else
     {
         FrequencyError newError = new FrequencyError(FrequencyErrorTypes.ResultLessThanDateMin);
         errors.Add(newError);
     }
     return resultDate;
 }
        private DateTime GetLastMonth()
        {
            int priorMonth = referenceDate.Month - 1;
            int yearOfPriorMonth = referenceDate.Year;
            if (priorMonth == 0)
            {
                priorMonth = 12;
                yearOfPriorMonth -= 1;
            }

            DateTime resultDate = DateTime.MinValue;
            if (YearNotLessThanMinimumYear(yearOfPriorMonth))
            {
                resultDate = new DateTime(yearOfPriorMonth, priorMonth, 1, 0, 0, 0);
            }
            else
            {
                FrequencyError newError = new FrequencyError(FrequencyErrorTypes.ResultLessThanDateMin);
                errors.Add(newError);
            }

            return resultDate;
        }