/// <summary> /// Gets an instance of <see cref="OpeningHoursDay"/> representing the day at the specified <code>date</code>. If <strong>Require Holiday Dates</strong> has /// been checked in the pre-value editor, holidays will be taken into account as well. /// </summary> /// <param name="date">The date.</param> /// <returns>Returns an instance of <see cref="OpeningHoursDay"/> representing the day at the specified <code>date</code>.</returns> public OpeningHoursDay GetDay(DateTime date) { // Get information about the weekday (and whether it is a holiday) WeekdayOpeningHours woh = Weekdays[date.DayOfWeek]; HolidayOpeningHours hoh = GetHoliday(date); // Initialize the instance for the day return(new OpeningHoursDay(date, woh, hoh)); }
public OpeningHoursDay(DateTime date, WeekdayOpeningHours weekday, HolidayOpeningHours holiday) { Date = date; Weekday = weekday; Holiday = holiday; IsOpen = holiday == null ? weekday.IsOpen : holiday.IsOpen; Label = holiday == null ? null : holiday.Label; Opens = date.Add(holiday == null ? weekday.Opens : holiday.Opens); Closes = date.Add(holiday == null ? weekday.Closes : holiday.Closes); }
/// <summary> /// Gets a reference to the holiday at the specified <code>date</code>, or <code>null</code> if the day doesn't /// represent a holiday. /// </summary> /// <param name="date">The date.</param> /// <param name="holiday">A reference to the holiday.</param> /// <returns>Returns <code>true</code> if the day represents a holiday, otherwise <code>false</code>.</returns> public bool TryGetHoliday(DateTime date, out HolidayOpeningHours holiday) { return(_holidays.TryGetValue(date.ToString("yyyyMMdd"), out holiday)); }