Holidays 1.0.1

.NET Standard 2.0 .NET Framework 4.0
dotnet add package Holidays --version 1.0.1
NuGet\Install-Package Holidays -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Holidays" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Holidays --version 1.0.1
#r "nuget: Holidays, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Holidays as a Cake Addin
#addin nuget:?package=Holidays&version=1.0.1

// Install Holidays as a Cake Tool
#tool nuget:?package=Holidays&version=1.0.1

Holidays

Library to provide a list of official holidays from an year. Get holidays for any year between 1901 and 2099. Also you can add custom holidays and manage with those dates as you wish.

Supported countries

Currently, the library has embedded support to the countries in table below, including moveable holidays.

Country Moveable holidays
Brazil Christian holidays
Portugal Christian holidays

Instalation

To install the Nuget package, run the following command in the Package Manager Console on Visual Studio:

PM> Install-Package Holidays

Or download package directly from Nuget.org

Usage

Basically, you can create an instance of NationalHolidays class or use the static methods and after chain the year to the OfYear method, as you want:

var year = System.DateTime.Today.Year;
var brazilianHolidaysOfYear = NationalHolidays.FromBrazil.OfYear(year);
// or
brazilianHolidaysOfYear = NationalHolidays.From("br").OfYear(year);

var protugueseHolidaysOfYear = NationalHolidays.FromPortugal.OfYear(year);
// or
protugueseHolidaysOfYear = NationalHolidays.From("pt").OfYear(year);

The result is a Dictionary<string, DateTime> that represents the holiday description and its repective date on those year.

Warning The library has embedded only the national holidays, but includes also those that move acording the Christian events, such as Carnival and Easter (using Gauss algorithm).

var christianHolidays = new ChristianHolidays(DateTime.Today.Year);
var carnivalDateOnYear = christianHolidays.Carnival;
var easterDateOnYear = christianHolidays.Easter;

If you are interested only in the fixed holidays, you could get them as below:

var brazilianFixedHolidays = NationalHolidays.FromBrazil.FixedHolidays;

Note that is not necessary inform the year. The return is a collection of Holiday objects, that contains the holiday description, the day, the month of the year and a holiday type (National, Observance, Optional, Local, Season, etc)

You can add your custom dates:

var customHolidayDate = new System.DateTime(System.DateTime.Today.Year, 5, 15);
holidays.AddCustom("some holiday", customHolidayDate);
// or
var customHoliday = new Holiday{ Description = "some holiday", Day = 1, Month = 2, Type = HolidayType.Local };
holidays.Add(customHoliday);
// or
holidays.AddRange(
   new Holiday{ Description = "some holiday 1", Day = 1, Month = 2, Type = HolidayType.Local }, 
   new Holiday { Description = "some holiday 2", Day = 2, Month = 3, Type = HolidayType.Local });
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Holidays:

Package Downloads
Evoluze.Roboluze

Biblioteca Dominio Fiscal

Roboluze.Libre.Config

Biblioteca de configurações

Roboluze.Config

Biblioteca de configurações

LiturgicalHolidays

Calculates Protestant holidays for any date between 1901 and 2099.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 7,425 11/5/2018

Added support for .Net Core 2.0 (under construction)