Skip to content
.NET Worldwide public holiday calculation
C# HTML Other
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Merge branch 'master' of https://github.com/nager/Nager.Date Feb 3, 2020
Doc/Icons Change folder structure Aug 29, 2017
Src
.gitattributes 🍭 Added .gitattributes & .gitignore files Aug 15, 2014
.gitignore
Dockerfile Merge branch 'master' of https://github.com/nager/Nager.Date Feb 3, 2020
LICENSE.md Optimize nuget package, optimize code example Jun 25, 2019
README.md Merge branch 'master' of https://github.com/nager/Nager.Date Feb 3, 2020
appveyor.yml Update appveyor.yml Dec 10, 2019

README.md

GitHub Release Build status Docker Image CI

Nager.Date (date.nager.at)

Nager.Date is a popular Date/Calendar library for Public holiday calculation for every year and supports over 100 countries. Nager.Date is open source software and is completely free for commercial use. You can choose if you want to use the project directly or if you want to use the API. If you need more as 50 requests per day please use directly.

How can I use it?

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

nuget

The package is available on nuget

PM> install-package Nager.Date

web api

  • direct use the api direct date.nager.at API
  • docker or use the docker container dockerhub
    • docker run -d -p 80:80 nagerat/nager-date

Donation possibilities

If this project help you reduce time to develop, you can give me a beer 🍺 Donate

Examples

Get all publicHolidays of a country and year

var publicHolidays = DateSystem.GetPublicHoliday("DE", 2017);
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(CountryCode.DE, startDate, endDate);
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");
}

Calculate age

var date = new DateTime(1900, 1, 1);
var age = DateSystem.GetAge(date);

Country Support

The list of supported countries can be found on the wiki.

Areas of Application

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

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
You can’t perform that action at this time.