/// <summary> /// Add business days on a DateTime /// </summary> /// <param name="date">Date to add days</param> /// <param name="days">Days to add</param> /// <returns>date</returns> public static DateTime AddBusinessDays(this DateTime date, int days) { return date.AddBusinessDays(days, null); }
/// <inheritdoc cref="OrPriorBusinessDay(DateTime, DateTime[])" /> public static DateTime? OrPriorBusinessDay(this DateTime? dateTime, params DateTime[] holidays) => dateTime.IsBusinessDay(holidays) ? dateTime : dateTime.AddBusinessDays(-1, holidays);
/// <inheritdoc cref="OrNextBusinessDay(DateTime, DayOfWeek[], DateTime[])" /> /// <remarks>Saturday and Sunday are weekend days.</remarks> public static DateTime OrNextBusinessDay(this DateTime dateTime, params DateTime[] holidays) => dateTime.IsBusinessDay(holidays) ? dateTime : dateTime.AddBusinessDays(1, holidays);
/// <inheritdoc cref="OrPriorBusinessDay(DateTime, DayOfWeek[], DateTime[])" /> public static DateTime? OrPriorBusinessDay(this DateTime? dateTime, DayOfWeek[] weekendDays, params DateTime[] holidays) => dateTime.IsBusinessDay(weekendDays, holidays) ? dateTime : dateTime.AddBusinessDays(-1, weekendDays, holidays);
/// <summary> /// Determines if the supplied <paramref name="dateTime" /> is a business day and if so returns it, otherwise returns /// the next business day /// </summary> /// <param name="dateTime">The DateTime to determine is a business day or not</param> /// <param name="weekendDays"> /// The days of the week to consider as the weekend. These days of the week will be excluded when /// determining business days. /// </param> /// <param name="holidays">Holidays dates to exclude when determining business days</param> /// <returns>The supplied <paramref name="dateTime" /> if it is a valid business day, otherwise the next business day</returns> public static DateTime OrNextBusinessDay(this DateTime dateTime, DayOfWeek[] weekendDays, params DateTime[] holidays) => dateTime.IsBusinessDay(weekendDays, holidays) ? dateTime : dateTime.AddBusinessDays(1, weekendDays, holidays);