/// <summary> /// Advances the specified date using the underlying calendar locations. /// </summary> /// <param name="locationsAsArray">The locations range as an array.</param> /// <param name="date">The date.</param> /// <param name="dayType">The day type: cakendat or business.</param> /// <param name="periodInteval">The period inteval.</param> /// <param name="businessDayConvention">The business day convention.</param> /// <returns>The adjusted date.</returns> public DateTime Advance(Excel.Range locationsAsArray, DateTime date, string dayType, string periodInteval, string businessDayConvention) { List <string> unqVals = DataRangeHelper.StripRange(locationsAsArray); var result = CalendarService.Advance(unqVals.ToArray(), date, dayType, periodInteval, businessDayConvention); return(result); }
/// <summary> /// Determines whether the specified date is a business day. /// </summary> /// <param name="locationsAsArray">The locations range as an array.</param> /// <param name="date">The date.</param> /// <returns></returns> public Boolean IsBusinessDay(Excel.Range locationsAsArray, DateTime date) { List <string> unqVals = DataRangeHelper.StripRange(locationsAsArray); var result = CalendarService.IsBusinessDay(unqVals.ToArray(), date); return(result); }
/// <summary> /// Adds the period to an array of dates. /// </summary> /// <param name="baseDate">The base dates.</param> /// <param name="dayType">The day type.</param> /// <param name="periodArray">The period interval array.</param> /// <param name="businessDayConvention">The business day convention.</param> /// <param name="location">The calendar. </param> /// <returns>A range of dates.</returns> public object[,] AddManyPeriods(DateTime baseDate, string dayType, Excel.Range periodArray, string businessDayConvention, string location) { List <string> periodVals = DataRangeHelper.StripRange(periodArray); List <DateTime> periods = CalendarService.AddPeriods(baseDate, dayType, periodVals.ToArray(), businessDayConvention, new[] { location }); var resVals = RangeHelper.ConvertArrayToRange(periods); return(resVals); }
/// <summary> /// Adds the period to an array of dates. /// </summary> /// <param name="dateArray">The dates as an array.</param> /// <param name="dayType">The day type.</param> /// <param name="periodInterval">The period interval.</param> /// <param name="businessDayConvention">The business day convention.</param> /// <param name="locationsAsArray">The calendars.</param> /// <returns>A range of dates.</returns> public object[,] AddPeriods(Excel.Range dateArray, string dayType, string periodInterval, string businessDayConvention, Excel.Range locationsAsArray) { List <string> unqVals = DataRangeHelper.StripRange(locationsAsArray); List <DateTime> dateVals = DataRangeHelper.StripDateTimeRange(dateArray); List <DateTime> periods = CalendarService.AddPeriods(dateVals.ToArray(), dayType, periodInterval, businessDayConvention, unqVals.ToArray()); var resVals = RangeHelper.ConvertArrayToRange(periods); return(resVals); }
/// <summary> /// Business days between a period. /// </summary> /// <param name="locationsAsArray">The locations range as an array.</param> /// <param name="startDate">The start date.</param> /// <param name="endDate">The end date.</param> /// <returns></returns> public object[,] BusinessDaysBetween(Excel.Range locationsAsArray, DateTime startDate, DateTime endDate) { List <string> unqVals = DataRangeHelper.StripRange(locationsAsArray); var list = CalendarService.BusinessDaysBetween(unqVals.ToArray(), startDate, endDate); var resVals = new object[list.Count, 1]; for (int idx = 0; idx < resVals.Length; ++idx) { resVals[idx, 0] = list[idx]; } return(resVals); }
/// <summary> /// Gets the adjusted calculation period start dates. /// </summary> /// <param name="effectiveDate">The effective date.</param> /// <param name="terminationDate">The termination date.</param> /// <param name="periodInterval">The period interval.</param> /// <param name="rollConvention">The roll convention.</param> /// <param name="firstRegularPeriodDate">The first regular period date.</param> /// <param name="stubPeriodType">Type of the stub period.</param> /// <param name="calendars">The holiday array.</param> /// <param name="businessDayConvention">The business day convention.</param> /// <returns>A vertival range of dates.</returns> public object[,] GetAdjustedCalculationPeriodDates(DateTime effectiveDate, DateTime terminationDate, string periodInterval, string rollConvention, DateTime firstRegularPeriodDate, string stubPeriodType, Excel.Range calendars, string businessDayConvention) { List <string> unqVals = DataRangeHelper.StripRange(calendars); IBusinessCalendar businessCalendar = CalendarService.GetCalendar(unqVals.ToArray()); var dates = AdjustedDateScheduler.GetAdjustedCalculationPeriodDates(effectiveDate, terminationDate, periodInterval, rollConvention, firstRegularPeriodDate, stubPeriodType, businessCalendar, businessDayConvention); var result = RangeHelper.ConvertArrayToRange(dates); return(result); }
/// <summary> /// Advances the specified date using the underlying calendar locations. /// </summary> /// <param name="locationsAsArray">The locations range as an array.</param> /// <param name="dateRange">The date.</param> /// <param name="dayType">The day type: cakendat or business.</param> /// <param name="periodInteval">The period inteval.</param> /// <param name="businessDayConvention">The business day convention.</param> /// <returns>The vertical range of adjusted dates.</returns> public object[,] AdvanceDateRange(Excel.Range locationsAsArray, Excel.Range dateRange, string dayType, string periodInteval, string businessDayConvention) { List <string> unqVals = DataRangeHelper.StripRange(locationsAsArray); List <DateTime> unqDates = DataRangeHelper.StripDateTimeRange(dateRange); List <DateTime> result = unqDates.Select(element => CalendarService.Advance(unqVals.ToArray(), element, dayType, periodInteval, businessDayConvention)).ToList(); var resVals = new object[result.Count, 1]; for (int idx = 0; idx < resVals.Length; ++idx) { resVals[idx, 0] = result[idx]; } return(resVals); }
/// <summary> /// Determines whether [is valid calendar] [the specified rule profile]. /// </summary> /// <param name="locationsAsArray">The locations as an array.</param> /// <returns></returns> public object[,] IsValidCalendar(Excel.Range locationsAsArray) { List <string> unqVals = DataRangeHelper.StripRange(locationsAsArray); IDictionary <string, Boolean> calendars = CalendarService.IsValidCalendar(unqVals.ToArray()); var collectionResult = calendars.Values; var resVals = new object[collectionResult.Count, 1]; var idx = 0; foreach (var result in collectionResult) { resVals[idx, 0] = result; idx++; } return(resVals); }
/// <summary> /// Rolls the specified date using the underlying calendar locations. /// </summary> /// <param name="locationsAsArray">The locations range as an array.</param> /// <param name="date">The date.</param> /// <param name="businessDayConvention">The business day convention.</param> /// <returns></returns> public DateTime Roll(Excel.Range locationsAsArray, DateTime date, string businessDayConvention) { List <string> unqVals = DataRangeHelper.StripRange(locationsAsArray); return(CalendarService.Roll(unqVals.ToArray(), date, businessDayConvention)); }