PublicHoliday 2.38.0

dotnet add package PublicHoliday --version 2.38.0
NuGet\Install-Package PublicHoliday -Version 2.38.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.38.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PublicHoliday --version 2.38.0
#r "nuget: PublicHoliday, 2.38.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.38.0

// Install PublicHoliday as a Cake Tool
#tool nuget:?package=PublicHoliday&version=2.38.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
    • USA : USANewYorkStockExchangeHoliday
  • S America
    • Brazil : BrazilPublicHoliday
  • 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 =  var holidayCalendar = new SwitzerlandPublicHoliday { Canton = SwitzerlandPublicHoliday.Cantons.OW };
var nationalDay = new DateTime(2024, 8, 1);
//yes it is
var isHoliday = calendar.IsPublicHoliday(nationalDay);

// We can also recover all the public holidays of all the cantons combined
var holidayCalendar = new SwitzerlandPublicHoliday { Canton = SwitzerlandPublicHoliday.Cantons.ALL };
IDictionary<DateTime, string> hols = holidayCalendar.PublicHolidays(2024);

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.38.0 433 4/7/2024
2.37.0 1,236 4/1/2024
2.36.0 10,134 3/10/2024
2.35.0 4,353 3/3/2024
2.34.0 71,039 12/5/2023
2.33.0 15,821 11/22/2023
2.32.0 50,775 10/4/2023
2.31.0 22,571 9/9/2023
2.30.0 79,022 7/24/2023
2.29.0 114,681 5/28/2023
2.28.0 24,335 5/6/2023
2.27.0 113,098 3/25/2023
2.26.0 63,308 3/12/2023
2.25.0 4,402 3/5/2023
2.24.0 30,357 2/7/2023
2.23.0 36,738 1/7/2023
2.22.0 231,778 12/8/2022
2.21.0 17,368 11/24/2022
2.20.0 24,538 11/6/2022
2.19.0 12,059 10/25/2022
2.18.0 2,661 10/22/2022
2.17.0 38,094 9/25/2022
2.16.2 17,458 9/12/2022
2.16.1 944 9/11/2022
2.16.0 34,568 8/19/2022
2.15.0 102,255 5/3/2022
2.14.0 81,275 1/4/2022
2.13.0 20,384 12/8/2021
2.12.0 4,408 11/18/2021
2.11.0 5,231 11/6/2021
2.10.0 5,083 10/25/2021
2.7.0 35,612 9/17/2021
2.6.0 45,037 7/4/2021
2.5.0 10,880 6/18/2021
2.3.0 127,112 11/12/2020
2.2.0 149,087 9/1/2020
2.1.0 36,783 7/11/2020
2.0.8 43,801 4/17/2020
2.0.7 89,467 9/14/2019
2.0.6 69,483 7/31/2019
2.0.5 12,606 6/17/2019
2.0.4 1,373 6/8/2019
2.0.3 57,678 3/8/2019
2.0.2 79,280 4/28/2018
2.0.1 12,928 2/17/2018
2.0.0 20,284 10/4/2017
1.8.0 7,390 6/5/2017
1.7.0 1,795 5/27/2017
1.6.0 1,766 5/7/2017
1.5.0 3,894 1/11/2017
1.4.0 16,804 11/3/2016
1.3.2 3,193 6/28/2016
1.3.2-beta2 1,591 5/31/2016
1.3.2-beta1 1,355 5/30/2016
1.3.1 12,104 1/4/2016
1.3.0 2,190 7/7/2015
1.2.0 1,853 7/1/2015
1.1.1 1,927 1/16/2015
1.1.0 2,401 4/29/2014
1.0.0 1,980 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+/andard1.3+ (thanks @Hrothval) Added RomanianPublicHoliday (thanks @mihaigliga21)
2.10.0: Add in HolidayCalculator PreviousWorkingDay/NextWorkingDay with x open day, Add eCachingHolidays with default to false in IPublicHolidays/PublicHolidayBase, Add in IsWorkingDay in ublicHolidays, Add target .NET 5.0 (thanks @Hrothval)
2.11.0: Add Estonia (thanks @Kaupo) Add USAFederalReserveHoliday (thanks @AndrewPecha). Add calizationString for France and US. Adjust framework for code section, CanadaQuebecGovClosingDay djustholiday name for past year CanadaDay and NationalPatriotDay, HolidayCalculator reviousWorkingDay/extWorkingDay option ignore same day, IPublicHolidays/PublicHolidayBase add eviousWorkingDayNotSameDay and NextWorkingDayNotSameDay, USAPublicHoliday add holiday name and andardization (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 eancallinan )
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 mpatibility/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 tionally only in Lustrum years) -Thanks @SeanSEmerson, @swannet)
2.29.0: Womans Day in Mecklenburg-Vorpommern since 2023, added Serbian holidays (thanks @Reo1980, lekseiKrasilnikov)
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 hanks @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 )
2.37.0: #120 Add Brazil holidays (thanks @rsegecin ), Netherlands add Good Friday (thanks @wdnijdam  )
2.38.0: #122 Update Switzerland Holiday with Cantons (thanks @tossnet), Add NYSE holidays  (thanks @stephenherrick )