static private DateTime GetNextMonthBracketBusinessDate(EmpiriaCalendar calendar, DateTime fromDate, int bracketMonthsSize, int bracketControlMonth, int businessDays) { var bracketsBuilder = new MonthBracketsBuilder(bracketMonthsSize, bracketControlMonth); MonthBracket bracket = bracketsBuilder.GetBracketFor(fromDate); int year = fromDate.Year; if (fromDate.Month > bracket.DueMonth) { year = year + 1; } DateTime date = new DateTime(year, bracket.DueMonth, 1).AddDays(-1); DateTime withWorkingDaysAdded = calendar.AddWorkingDays(date, businessDays); if (withWorkingDaysAdded.Month == bracket.DueMonth) { return(withWorkingDaysAdded); } else { return(calendar.LastWorkingDateWithinMonth(year, bracket.DueMonth)); } }
static private DateTime GetNextMonthBracketDate(DateTime fromDate, int bracketMonthsSize, int bracketControlMonth, int bracketMonthDueDay) { var bracketsBuilder = new MonthBracketsBuilder(bracketMonthsSize, bracketControlMonth); MonthBracket bracket = bracketsBuilder.GetBracketFor(fromDate); int year = fromDate.Year; if (fromDate.Month > bracket.DueMonth) { year = year + 1; } return(new DateTime(year, bracket.DueMonth, bracketMonthDueDay)); }