/Nager.Date

:earth_americas: Worldwide public holiday

Primary LanguageC#MIT LicenseMIT

Build status Docker Image CI

📆 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

Country Support

The list of supported countries can be found here.

How can I use it?

If you are use .net you can install the package via nuget for all other languages we have a docker image with a web api available.

nuget

The package is available via nuget

PM> install-package Nager.Date

web api

  • public use the public api date.nager.at API
    • If you need more as 50 requests per day please use your own private api (docker).
  • private use the docker container available on dockerhub
    • To run a local instance of the docker image run the following command
      docker run -e "EnableCors=true" -e "EnableIpRateLimiting=false" -e "EnableSwaggerMode=true" -p 80:80 nager/nager-date
      • EnableCors=true activate CORS support
      • EnableIpRateLimiting=false disable IpRateLimiting
      • EnableSwaggerMode=true activate Swagger UI as start page
      • -p 80:80 publish the port 80 from the docker to your host.

Sponsor us

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...

Examples for .NET (nuget package)

Get all publicHolidays of a country and year

var publicHolidays = DateSystem.GetPublicHoliday(2017, "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
}

Get all publicHolidays for a date range

var startDate = new DateTime(2016, 5, 1);
var endDate = new DateTime(2018, 5, 31);
var publicHolidays = DateSystem.GetPublicHoliday(startDate, endDate, CountryCode.DE);
foreach (var publicHoliday in publicHolidays)
{
	//publicHoliday...
}

Check if a date is a public holiday

var date = new DateTime(2017, 1, 1);
if (DateSystem.IsPublicHoliday(date, CountryCode.DE))
{
    Console.WriteLine("Is public holiday");
}

Check if a date is a weekend day

var date = new DateTime(2017, 1, 1);
if (DateSystem.IsWeekend(date, CountryCode.DE))
{
    Console.WriteLine("Is weekend");
}

Areas of Application

  • telephone systems
  • carrier (land transport)
  • time recording

Who uses Nager.Date?

Your company here Your company here Your company here Your company here

Blog Posts

Mark Seemann - Simple holidays

Alternative projects

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