public void Setup() { CalanderDao dao = new CalanderDao(); // For testing, jan1, july4, christmas. List <Holiday> holidays = new List <Holiday>() { new Holiday(1, 1, true, DayOfWeek.Monday, -1, "New Years"), new Holiday(7, 4, true, DayOfWeek.Monday, -1, "Independence Day"), new Holiday(12, 25, true, DayOfWeek.Monday, -1, "Christmas Day") }; dao.Load("usa-bronx-holidays", holidays); Calendar.Init("usa-bronx-holidays", dao, DateTime.Today.Year, DateTime.Today.Year + 1); }
/// <summary> /// Run the application. /// </summary> public override BoolMessageItem Execute() { // 1. Use the default holiday calendar loaded with U.S. holidays. // What is next business date after 1/1/<current_year> DateTime nextBusDay = Calendar.NextBusinessDate(new DateTime(DateTime.Today.Year, 1, 1)); DateTime previousBusinessDay = Calendar.PreviousBusinessDate(new DateTime(DateTime.Today.Year, 1, 1)); // 2. Use other holiday calendar. // NOTE:( Current implementation only uses hard dates ( no-relative dates 3rd thursday of november ) // can be supplied. This limitation will be fixed. CalanderDao calDao = new CalanderDao("kishore's_holiday_calendar", GetSampleHolidays()); ICalendar cal = new CalendarService("kishore's_holiday_calendar", calDao, 5); nextBusDay = cal.NextBusinessDate(DateTime.Today); Console.WriteLine("Next business date using \"kishore's_holiday_calendar\" : " + nextBusDay.ToString()); return(BoolMessageItem.True); }