📆 Nager.Date - Official Website
Nager.Date is a popular project to query holidays. We currently support over 100 countries. The project is based on .NET but provides a REST interface to retrieve the data. There are several ways to use Nager.Date, there is a public api, you can start your own docker container or you can use the nuget package.
Nager.Date is open source software and is completely free for commercial use. If you would like to support the project you can award a GitHub star ⭐ or even better actively support us
Starting May 1, 2022, the Docker container and the NuGet package will require a Licence Key provided to the sponsors of this project. The public WebApi will remain freely accessible.
The list of supported countries can be found here.
If you are use .NET you can install the package via nuget, for all other languages we have a public web api available. If you have restrictive regulations in your company or you need high availability then you can also use the Docker Container.
The package is available via NuGet
PM> install-package Nager.Date
- public use the public api date.nager.at
- If you need the Api for a large number of requests, we also provide a Docker container.
- self-hosted (docker) use your own api, the docker container is available on Docker Hub
- To run a local instance of the docker image run the following command
docker run -p 80:80 nager/nager-date
-p 80:80
publish the port 80 from the docker to your host.
- To run a local instance of the docker image run the following command
You can use swagger-codegen-cli
to create a client for the api
docker run --rm -v C:\Temp:/local swaggerapi/swagger-codegen-cli-v3 generate -i https://date.nager.at/swagger/v1.0/swagger.json -l csharp-dotnet2 -o /local/out
Your sponsorship helps us spend more time working on OpenSource related to Nager.Date, become a sponsor now. We started in 2014 and look forward to many more years...
var publicHolidays = DateSystem.GetPublicHolidays(2021, "DE");
foreach (var publicHoliday in publicHolidays)
{
//publicHoliday...
//publicHoliday.Date -> The date
//publicHoliday.LocalName -> The local name
//publicHoliday.Name -> The english name
//publicHoliday.Fixed -> Is this public holiday every year on the same date
//publicHoliday.Global -> Is this public holiday in every county (federal state)
//publicHoliday.Counties -> Is the public holiday only valid for a special county ISO-3166-2 - Federal states
//publicHoliday.Type -> Public, Bank, School, Authorities, Optional, Observance
}
var startDate = new DateTime(2016, 5, 1);
var endDate = new DateTime(2021, 5, 31);
var publicHolidays = DateSystem.GetPublicHolidays(startDate, endDate, CountryCode.DE);
foreach (var publicHoliday in publicHolidays)
{
//publicHoliday...
}
var date = new DateTime(2021, 1, 1);
if (DateSystem.IsPublicHoliday(date, CountryCode.DE))
{
Console.WriteLine("Is public holiday");
}
var date = new DateTime(2021, 1, 1);
if (DateSystem.IsWeekend(date, CountryCode.DE))
{
Console.WriteLine("Is weekend");
}
- telephone systems
- carrier (land transport)
- time recording
Mark Seemann - Simple holidays
Language | Project | Supported Countries (January 2019) |
---|---|---|
PHP | yasumi | 34 |
JavaScript | date-holidays | 142 |
Java | jollyday | 64 |
.NET | Holiday | 21 |
Python | python-holidays | 34 |
Python | workalendar | 59 |