Nager.Date supports over 110 countries (US, DE, FR, RU, UK, …) the library is available for netstandard2.1. The full list of supported countries can be found here.
Update 2023
A new NuGet package is available. This means that the holidays are now queried by the WebApi and can be easily updated without having to update the NuGet package every time.
Nuget
PM> install-package Nager.Holiday
Example:
Get all publicHolidays of a year
using var holidayClient = new HolidayClient();
var holidays = await holidayClient.GetHolidaysAsync(2023, "de");
Check if a date a public holiday
using var holidayClient = new HolidayClient();
var holidays = await holidayClient.GetHolidaysAsync(checkDate.Year, "de");
if (holidays.Any(o => o.Date == checkDate))
{
//Yes - New Year's Day
}
Previous answer
Nuget
PM> install-package Nager.Date
Example:
Get all publicHolidays of a year
var publicHolidays = DateSystem.GetPublicHoliday(2018, CountryCode.DE);
Check if a date a public holiday
var date = new DateTime(2018, 01, 01);
if (DateSystem.IsPublicHoliday(date, CountryCode.DE))
{
//Yes - New Year's Day
}