PublicHoliday 2.40.0
See the version list below for details.
dotnet add package PublicHoliday --version 2.40.0
NuGet\Install-Package PublicHoliday -Version 2.40.0
<PackageReference Include="PublicHoliday" Version="2.40.0" />
paket add PublicHoliday --version 2.40.0
#r "nuget: PublicHoliday, 2.40.0"
// Install PublicHoliday as a Cake Addin #addin nuget:?package=PublicHoliday&version=2.40.0 // Install PublicHoliday as a Cake Tool #tool nuget:?package=PublicHoliday&version=2.40.0
Public Holidays
Nuget: Install-Package PublicHoliday
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
- Portugal : PortugalPublicHoliday ()
- Romania : RomanianPublicHoliday
- Serbia : SerbianPublicHoliday
- Slovakia : SlovakiaPublicHoliday
- Spain : SpainPublicHoliday
- Slovenia : SloveniaPublicHoliday
- Sweden : SwedenPublicHoliday
- Switzerland: SwitzerlandPublicHoliday
- UK : UKBankHoliday (set UkCountry property for Scotland/Northern Ireland variations)
-
- 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 France the calendar comes with holidays valid in all the country.
// Get the list of public holidays for 2024
IList<DateTime> result = new FrancePublicHoliday().PublicHolidays(2024);
// Get the list of public holidays name for 2024
IList<DateTime> result = new FrancePublicHoliday().PublicHolidayNames(2024);
// Get the list of public holidays name and date for 2024
IDictionary<DateTime, string> result = new FrancePublicHoliday().PublicHolidayNames(2024);
A method returns a list of objects for all public holidays, with the names of the regions concerned for each date :
var calendar = new FrancePublicHoliday { Region = FrancePublicHoliday.Regions.Martinique };
// Get the 14 dates for the public holidays in Martinique for 2024
var hols = calendar.PublicHolidays(2024);
// We can also recover all the public holidays of all the regions combined
var calendar = new FrancePublicHoliday { };
IDictionary<DateTime, string> hols = calendar.PublicHolidays(2024);
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);
A method returns a list of objects for all public holidays, with the names of the regions concerned for each date :
var holidayCalendar = new SwitzerlandPublicHoliday();
IList<Holiday> hols = holidayCalendar.PublicHolidaysComplete(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
- If you use Visual Studio 2022 open PublicHoliday.sln (.net 6.0)
- You cannot use the command line "dotnet build" because Core tooling cannot build v3.5 (see https://github.com/Microsoft/msbuild/issues/1333)
Product | Versions 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. |
-
.NETFramework 3.5
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.0)
-
.NETStandard 2.1
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on PublicHoliday:
Package | Downloads |
---|---|
PsA3Forms
Package Description |
|
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 |
---|---|---|
3.1.0 | 198 | 11/29/2024 |
3.0.0 | 10,091 | 11/11/2024 |
2.41.0 | 100,411 | 9/3/2024 |
2.40.0 | 36,390 | 8/12/2024 |
2.39.0 | 105,326 | 5/27/2024 |
2.38.0 | 108,610 | 4/7/2024 |
2.37.0 | 13,952 | 4/1/2024 |
2.36.0 | 50,785 | 3/10/2024 |
2.35.0 | 7,939 | 3/3/2024 |
2.34.0 | 176,172 | 12/5/2023 |
2.33.0 | 29,776 | 11/22/2023 |
2.32.0 | 84,136 | 10/4/2023 |
2.31.0 | 30,669 | 9/9/2023 |
2.30.0 | 104,779 | 7/24/2023 |
2.29.0 | 146,349 | 5/28/2023 |
2.28.0 | 26,390 | 5/6/2023 |
2.27.0 | 132,833 | 3/25/2023 |
2.26.0 | 74,767 | 3/12/2023 |
2.25.0 | 4,793 | 3/5/2023 |
2.24.0 | 35,297 | 2/7/2023 |
2.23.0 | 46,526 | 1/7/2023 |
2.22.0 | 304,567 | 12/8/2022 |
2.21.0 | 19,909 | 11/24/2022 |
2.20.0 | 30,502 | 11/6/2022 |
2.19.0 | 17,761 | 10/25/2022 |
2.18.0 | 3,453 | 10/22/2022 |
2.17.0 | 40,263 | 9/25/2022 |
2.16.2 | 18,545 | 9/12/2022 |
2.16.1 | 1,005 | 9/11/2022 |
2.16.0 | 44,745 | 8/19/2022 |
2.15.0 | 119,385 | 5/3/2022 |
2.14.0 | 89,212 | 1/4/2022 |
2.13.0 | 21,144 | 12/8/2021 |
2.12.0 | 4,570 | 11/18/2021 |
2.11.0 | 5,818 | 11/6/2021 |
2.10.0 | 5,148 | 10/25/2021 |
2.7.0 | 38,000 | 9/17/2021 |
2.6.0 | 48,810 | 7/4/2021 |
2.5.0 | 12,445 | 6/18/2021 |
2.3.0 | 135,277 | 11/12/2020 |
2.2.0 | 165,524 | 9/1/2020 |
2.1.0 | 38,159 | 7/11/2020 |
2.0.8 | 46,554 | 4/17/2020 |
2.0.7 | 96,386 | 9/14/2019 |
2.0.6 | 70,817 | 7/31/2019 |
2.0.5 | 14,037 | 6/17/2019 |
2.0.4 | 1,430 | 6/8/2019 |
2.0.3 | 59,706 | 3/8/2019 |
2.0.2 | 81,705 | 4/28/2018 |
2.0.1 | 13,160 | 2/17/2018 |
2.0.0 | 23,060 | 10/4/2017 |
1.8.0 | 8,132 | 6/5/2017 |
1.7.0 | 1,860 | 5/27/2017 |
1.6.0 | 1,826 | 5/7/2017 |
1.5.0 | 3,968 | 1/11/2017 |
1.4.0 | 23,671 | 11/3/2016 |
1.3.2 | 3,325 | 6/28/2016 |
1.3.2-beta2 | 1,653 | 5/31/2016 |
1.3.2-beta1 | 1,406 | 5/30/2016 |
1.3.1 | 12,270 | 1/4/2016 |
1.3.0 | 2,251 | 7/7/2015 |
1.2.0 | 1,905 | 7/1/2015 |
1.1.1 | 1,978 | 1/16/2015 |
1.1.0 | 2,463 | 4/29/2014 |
1.0.0 | 2,319 | 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 )
2.39.0: #125 Fix Turkey Ramadan and FeastOfSacrifices holidays (thanks @hasankaplan-github), #128 Update Switzerland Holiday (thanks @tossnet),; #131 Update France holiday with overseas territories (thanks @tossnet); #132 Add Portugal Holiday (thanks @greybird); #133 South Africa 2024 election day (thanks @FifoTheHein)
2.40.0: #135 Bavarian Assumption date is conditional