-
-
Notifications
You must be signed in to change notification settings - Fork 383
Holidays
kappy edited this page Mar 27, 2012
·
4 revisions
From version 1.1, there's also an extension avaible to list all year Holidays.
IDictionary<DateTime, Holiday> AllYearHolidays()
Thru this extension on DateTime, it's possible to get all holidays for a given culture and his ocurrences on its year, like in the next example:
[Test]
public void get_this_year_holidays_in_portugal() {
var portugalDateTimeCultureInfo = new DateTimeCultureInfo("pt-PT");
var today = DateTime.Today;
var holidays = today.AllYearHolidays();
Assert.IsTrue(holidays.Count == 13);
foreach (DateTime holidayDate in holidays.Keys) {
var holiday = holidays[holidayDate];
Assert.IsTrue(holidayDate.IsWorkingDay(portugalDateTimeCultureInfo) == false, "holiday {0} shouln't be working day in Portugal", holiday.Name);
}
}
Check out the project ReadMe for a list of supported cultures
If your culture is not specified here, feel free to fork this project and contribute it. I'll add some cultures from time to time.