Calculate public and federal holidays for a given year with native and English translations. Supports countries and subdivisions, covering over 100 countries worldwide.
$ dotnet add package Nager.DateNager.Date is a popular project for querying holidays, we currently support for over 110 countries.
The list of supported countries can be found here
HolidaySystem.LicenseKey = "TheLicenseKey";
var licenseKey = "TheLicenseKey";
var licenseInfo = Nager.Date.Helpers.LicenseHelper.CheckLicenseKey(licenseKey);
if (licenseInfo is null)
{
//license key invalid
return;
}
if (licenseInfo.ValidUntil < DateTime.Today)
{
//license key expired
return;
}
var holidays = HolidaySystem.GetHolidays(2024, "DE");
foreach (var holiday in holidays)
{
Console.WriteLine($"{holiday.Date:yyyy-MM-dd} - {holiday.EnglishName}");
//holiday...
//holiday.Date -> The date
//holiday.ObservedDate -> The date on which the holiday is observed
//holiday.LocalName -> The local name
//holiday.EnglishName -> The english name
//holiday.NationalHoliday -> Is this holiday in every county (federal state)
//holiday.SubdivisionCodes -> Is the holiday only valid for a special county ISO-3166-2 - Federal states
//holiday.HolidayTypes -> Public, Bank, School, Authorities, Optional, Observance
}
var startDate = new DateTime(2016, 5, 1);
var endDate = new DateTime(2024, 5, 31);
var holidays = HolidaySystem.GetHolidays(startDate, endDate, CountryCode.DE);
foreach (var holiday in holidays)
{
//holiday...
}
var date = new DateTime(2024, 1, 1);
if (HolidaySystem.IsPublicHoliday(date, CountryCode.DE))
{
Console.WriteLine("Is a public holiday");
}
var date = new DateTime(2024, 1, 1);
if (WeekendSystem.IsWeekend(date, CountryCode.DE))
{
Console.WriteLine("The date is in the weekend");
}
19.9M