PublicHoliday 2.36.0

dotnet add package PublicHoliday --version 2.36.0
NuGet\Install-Package PublicHoliday -Version 2.36.0
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="PublicHoliday" Version="2.36.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PublicHoliday --version 2.36.0
#r "nuget: PublicHoliday, 2.36.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PublicHoliday as a Cake Addin
#addin nuget:?package=PublicHoliday&version=2.36.0

// Install PublicHoliday as a Cake Tool
#tool nuget:?package=PublicHoliday&version=2.36.0

Public Holidays

Nuget: Install-Package PublicHoliday Nuget

Orders and deliveries, data transfers, and other processes can often only be made on business working days. They cannot be made on national public holidays. Public holidays in many countries can be calculated algorithmically.

//get a list of all holidays for 2017
IList<DateTime> result = new USAPublicHoliday().PublicHolidays(2017);

//get the next working day
DateTime dayAfterColumbus = new USAPublicHoliday().NextWorkingDay(new DateTime(2006, 10, 8)); //returns 10 October 2006

//2nd January 2006 is a Monday. But because 1st January was a Sunday, the bank holiday is the next Monday
bool isHoliday = new UKBankHoliday().IsBankHoliday(new DateTime(2006, 1, 2)); //returns true

//what's the next working day after Sunday 24th December 2006?
DateTime nextWorkingDay = new UKBankHoliday().NextWorkingDay(new DateTime(2006, 12, 24)); //returns 27 December 2006

The library contains adjustments for one-off holidays.

//Next working day after royal wedding - next working day is Tuesday 3rd May (Monday 2nd is MayDay)
DateTime nextWorkingDayAfterRoyalWedding = new UKBankHoliday().NextWorkingDay(new DateTime(2011, 4, 29));

There are libraries for:

  • Europe
    • Austria : AustriaPublicHoliday
    • Belgium : BelgiumPublicHoliday
    • Czech Republic : CzechRepublicPublicHoliday
    • ECB : EcbTargetClosingDay (European Central Bank SEPA Target Closing days - no exchange rates and no SEPA transactions)
    • Denmark : DenmarkPublicHoliday
    • Estonia : EstoniaPublicHoliday
    • Finland: FinlandPublicHoliday
    • France : FrancePublicHoliday
    • Germany : GermanPublicHoliday (set State property for regional holidays)
    • Greece : GreecePublicHoliday
    • Ireland : IrelandPublicHoliday
    • Italy : ItalyPublicHoliday
    • Lithuania : LithuaniaPublicHoliday
    • Luxembourg : LuxembourgPublicHoliday
    • Montenegro : MontenegroPublicHoliday
    • Netherlands : DutchPublicHoliday
    • Norway : NorwayPublicHoliday
    • Poland : PolandPublicHoliday
    • Romania : RomanianPublicHoliday
    • Serbia : SerbianPublicHoliday
    • Slovakia : SlovakiaPublicHoliday
    • Spain : SpainPublicHoliday
    • Slovenia : SloveniaPublicHoliday
    • Sweden : SwedenPublicHoliday
    • Switzerland: SwitzerlandPublicHoliday
    • UK : UKBankHoliday (set UkCountry property for Scotland/Northern Ireland variations)
    1. Europe/Asia
    • Kazakhstan : KazakhstanPublicHoliday
    • Turkey : TurkeyPublicHoliday
  • N America
    • Canada : CanadaPublicHoliday (set Province in constructor for regional holidays)
    • Canada : CanadaQuebecGovClosingDay (Government province of Quebec closing day)
    • USA : USAPublicHoliday
    • USA : USAFederalReserveHoliday
  • Oceania
    • Australia : AustraliaPublicHoliday (set State property for regional holidays, see note below)
    • New Zealand : NewZealandPublicHoliday
  • Asia
    • Japan : JapanPublicHoliday

All use the common interface IPublicHoliday containing:

  • IsPublicHoliday(DateTime) (UK: also IsBankHoliday(DateTime))
  • IsWorkingDay(DateTime) (i.e. not public holiday, Saturday or Sunday)
  • NextWorkingDay(DateTime)
  • NextWorkingDay(DateTime, int)
  • NextWorkingDayNotSameDay(DateTime)
  • NextWorkingDayNotSameDay(DateTime, int)
  • PreviousWorkingDay(DateTime)
  • PreviousWorkingDay(DateTime, int)
  • PreviousWorkingDayNotSameDay(DateTime)
  • PreviousWorkingDayNotSameDay(DateTime, int)
  • PublicHolidays(int year)
  • PublicHolidaysInformation(int year)
  • PublicHolidayNames(int year)
  • GetHolidaysInDateRange(DateTime, DateTime)
  • UseCachingHolidays

There are also static methods for all statutory holidays.

Weekend Rules

For many countries, when holidays fall on a weekend, the next working Monday becomes a public holiday (this is sometimes called "Mondayised"). This is the general rule in the UK, and used for certain (but not all) holidays in Australia and New Zealand.

In the USA, when holidays fall on Sundays, the holiday is moved to Monday. When the holiday falls on Saturday, the holiday is moved to the preceding Friday. The USA Federal Reserve holidays differ slightly, as holidays that fall on a Saturday do not cause a closure on the preceding Friday as described on the Federal Reserve's website.

For most of Europe, there is no standard rule for when the holidays fall on weekends. Normally these days are just added to the annual leave.

Variations by states and province

In Canada there are some provincial holidays that vary by region. You can access these by passing in the ISO Code of the province to the constructor

//Retrieve a list of holidays in Saskatchewan for 2016
IList<DateTime> result = new CanadaPublicHoliday("SK").PublicHolidays(2016);

In Germany specify the state using an enum (the ISO code)

//Calendar for Saxony
var calendar = new GermanPublicHoliday { State = GermanPublicHoliday.States.SN };
IList<DateTime> result = calendar.PublicHolidays(2017);
//result contains 22 November 2017, Repentance and Prayer Day

In United Kingdom England/Wales is default. Specify Scotland or Northern Ireland using an enum

//Calendar for Scotland
var calendar = new UKBankHoliday { UkCountry = UKBankHoliday.UkCountries.Scotland };
IList<DateTime> result = calendar.PublicHolidays(2022);
//result contains 30 November 2022, St Andrew's Day

In Switzerland the calendar comes with holidays valid in all the country. Add further ones depending on your local rules in the constructor. Choices: hasSecondJanuary, hasLaborDay, hasCorpusChristi, hasChristmasEve, hasNewYearsEve.

var calendar = SwitzerlandPublicHoliday(hasLaborDay:true);
var laborDay = new DateTime(2017, 5, 1);
//yes it is
var isHoliday = calendar.IsPublicHoliday(laborDay);

In Australia most holidays are defined by the state or territory. Specify the state using an enum (the ISO code).

//Calendar for Western Australia
var calendar = AustraliaPublicHoliday { State = AustraliaPublicHoliday.States.WA };
var westernAustrliaDay = new DateTime(2017, 6, 5);
//yes it is
var isHoliday = holidayCalendar.IsPublicHoliday(westernAustrliaDay);

IMPORTANT A few Australia state holidays do not have fixed rules, and cannot be calculated.

  • For Victoria, AFL Grand Final Day
  • For Western Australia, Queen's Birthday (we assume end September BUT may change)
  • The calendar does not contain local holidays (Royal Queensland Show day, Royal Hobart Regatta)

Thanks

@petergaal @msmells @oliver-h @DanielSundberg @kant2002 @zanemcca @jcdekoning @thelious @rickbeerendonk @skipishere @MilkyWare @Hrothval @mihaigliga21

License

License is MIT. You are free to use this software in commercial projects.

Building the Source

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 is compatible. 
.NET Framework net35 is compatible.  net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETStandard 1.3

  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PublicHoliday:

Package Downloads
DateFunctions

Set of common commands for calculating previous working days, bank holidays and working days

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.36.0 6,183 3/10/2024
2.35.0 3,454 3/3/2024
2.34.0 64,962 12/5/2023
2.33.0 14,945 11/22/2023
2.32.0 48,692 10/4/2023
2.31.0 22,207 9/9/2023
2.30.0 77,220 7/24/2023
2.29.0 112,526 5/28/2023
2.28.0 24,047 5/6/2023
2.27.0 110,218 3/25/2023
2.26.0 62,677 3/12/2023
2.25.0 4,387 3/5/2023
2.24.0 29,886 2/7/2023
2.23.0 36,218 1/7/2023
2.22.0 227,453 12/8/2022
2.21.0 17,246 11/24/2022
2.20.0 24,227 11/6/2022
2.19.0 11,793 10/25/2022
2.18.0 2,588 10/22/2022
2.17.0 37,965 9/25/2022
2.16.2 17,367 9/12/2022
2.16.1 935 9/11/2022
2.16.0 33,773 8/19/2022
2.15.0 101,508 5/3/2022
2.14.0 80,748 1/4/2022
2.13.0 20,290 12/8/2021
2.12.0 4,375 11/18/2021
2.11.0 5,184 11/6/2021
2.10.0 5,060 10/25/2021
2.7.0 35,429 9/17/2021
2.6.0 44,871 7/4/2021
2.5.0 10,768 6/18/2021
2.3.0 126,654 11/12/2020
2.2.0 147,953 9/1/2020
2.1.0 36,535 7/11/2020
2.0.8 43,676 4/17/2020
2.0.7 89,074 9/14/2019
2.0.6 68,946 7/31/2019
2.0.5 12,516 6/17/2019
2.0.4 1,358 6/8/2019
2.0.3 57,531 3/8/2019
2.0.2 79,151 4/28/2018
2.0.1 12,893 2/17/2018
2.0.0 20,196 10/4/2017
1.8.0 7,318 6/5/2017
1.7.0 1,780 5/27/2017
1.6.0 1,756 5/7/2017
1.5.0 3,867 1/11/2017
1.4.0 16,584 11/3/2016
1.3.2 3,144 6/28/2016
1.3.2-beta2 1,580 5/31/2016
1.3.2-beta1 1,326 5/30/2016
1.3.1 12,070 1/4/2016
1.3.0 2,175 7/7/2015
1.2.0 1,837 7/1/2015
1.1.1 1,913 1/16/2015
1.1.0 2,388 4/29/2014
1.0.0 1,959 11/16/2013

2.0.2: Fix for AU-NSW-2016 (thanks @dotnetshadow)
2.0.3: Canada BC changing family day from 2019
2.0.4: UK Early May Day 2020 moved (thanks @skipishere)
2.0.5: UK Early May Day 2020 Monday (thanks @deltafsdevelopment )
2.0.6: IsWorkingDay added (thanks @MilkyWare)
2.0.7: DE recent changes (thanks @janaw)
2.0.8: Austria 2008 error (thanks @OtmarP)
2.1.0: South Africa added (thanks @cltw666)
2.2.0: Japan 2020 error (thanks @overstimulated)
2.3.0: UK 2022 Queen's Platinum Jubilee
2.4.0: Scotland, Northern Island holidays (thanks @stuart-lawrence)
2.5.0: US 2021 Juneteenth added
2.6.0: New Zealand Matariki dates added for next 30 years
2.7.0: Add Denmark (thanks @Halling69), add Canada Truth&Reconciliation from 2021 (thanks @mattandwhatnot), change Japan Emperors Day (thanks @zimathon)
2.8.0: Add Canada Governement Quebec Closing Day , improve HolidayCalculator (thanks @Hrothval)
2.9.0: Add Localized String for class Holiday, Adding cache for Easter for performance framework 4.0+/standard1.3+ (thanks @Hrothval) Added RomanianPublicHoliday (thanks @mihaigliga21)
2.10.0: Add in HolidayCalculator PreviousWorkingDay/NextWorkingDay with x open day, Add UseCachingHolidays with default to false in IPublicHolidays/PublicHolidayBase, Add in IsWorkingDay in IPublicHolidays, Add target .NET 5.0 (thanks @Hrothval)
2.11.0: Add Estonia (thanks @Kaupo) Add USAFederalReserveHoliday (thanks @AndrewPecha). Add LocalizationString for France and US. Adjust framework for code section, CanadaQuebecGovClosingDay adjust holiday name for past year CanadaDay and NationalPatriotDay, HolidayCalculator PreviousWorkingDay/NextWorkingDay option ignore same day, IPublicHolidays/PublicHolidayBase add PreviousWorkingDayNotSameDay and NextWorkingDayNotSameDay, USAPublicHoliday add holiday name and standardization (thanks @Hrothval)
2.12.0: Fix DutchPublicHoliday LiberationDay (thanks @sergiu05)
2.13.0: Fix ANZAC/Easter Monday conflict (thanks @seancallinan )
2.14.0: #66 Add holiday names for USAFederalReserveHoliday
2.15.0: #67 Fix spelling Switzerland Pfingsten
2.16.0 #69 Add Lithuania (thanks @aursad)
2.16.2 #72 Add state funeral of Queen Elizabeth II, UK, Canada, Australia, New Zealand (thanks @seancallinan )
2.17.0 #73 NZ provincial holidays added (thanks @seancallinan ) #74 Germany holiday error
2.18.0 #77 South african public holidays fixes (thanks @FifoTheHein ) #78 Added polish diacritics (thanks @konradbartecki )
2.19.0 #79 Added Turkey (thanks @HakanUcaar )
2.20.0 Added UK special holiday for Coronation, 2023
2.21.0 #81 Added Slovenian holidays (thanks @KlemenS189 )
2.22.0: #82 South Africa Christmas dates moved (thanks @ FifoTheHein )
2.23.0: #83 Add Finland holidays (thanks @vergi40 )
2.24.0: Ireland adds St Brigid's day from 2023
2.25.0: Australia + New Zealand- King's Birthday added (Queen's Birthday retained for backwards API compatibility/historic dates), Denmark remove General Prayer Day from 2024 (thanks @Jesper Nysteen)
2.26.0: Add Greece holidays
2.27.0: Fix issues with Turkey Holidays (thanks @ahmet-cetinkaya )
2.28.0: #94 #96 Conditional holidays in Denmark (day after Ascension) and Netherlands (Liberation Day optionally only in Lustrum years) -Thanks @SeanSEmerson, @swannet)
2.29.0: Womans Day in Mecklenburg-Vorpommern since 2023, added Serbian holidays (thanks @Reo1980, @AlekseiKrasilnikov)
2.30.0: #102 Add Montenegro holidays (thanks @anovik); add netstandard2.1 target, no other changes
2.31.0: #103 Add missing holidays for Brandenburg (thanks @Cryma); #104 Germany: Assumption in Bavaria (thanks @mkrso )
2.32.0: #107 Serbia orthodox easter (thanks @anovik); #108 UK boxing day rules (thanks @spetsen)
2.33.0: #113 #112 Ireland holidays fix weekend rules (thanks @Bjornsen016)
2.34.0: #114 South Africa - Special holiday - 2023 Rugby World Cup Win (thanks @FifoTheHein)
2.35.0: #115 Fixed Japanese Equinox Day calculation (thanks @Makaopior )
2.36.0: #116 Fixed Japanese Vernal and Autumnal Equinox days (thanks @Makaopior )