![]() |
VOOZH | about |
dotnet add package mitoSoft.Holidays --version 2.0.7
NuGet\Install-Package mitoSoft.Holidays -Version 2.0.7
<PackageReference Include="mitoSoft.Holidays" Version="2.0.7" />
<PackageVersion Include="mitoSoft.Holidays" Version="2.0.7" />Directory.Packages.props
<PackageReference Include="mitoSoft.Holidays" />Project file
paket add mitoSoft.Holidays --version 2.0.7
#r "nuget: mitoSoft.Holidays, 2.0.7"
#:package mitoSoft.Holidays@2.0.7
#addin nuget:?package=mitoSoft.Holidays&version=2.0.7Install as a Cake Addin
#tool nuget:?package=mitoSoft.Holidays&version=2.0.7Install as a Cake Tool
A lightweight, extensible .NET library for determining holidays across different countries and their administrative divisions.
mitoSoft.Holidays is a comprehensive holiday management library that provides:
Install via NuGet Package Manager:
Install-Package mitoSoft.Holidays
Or via .NET CLI:
dotnet add package mitoSoft.Holidays
Administrative divisions are geographical areas into which a country is divided. Different countries have different types of administrative divisions:
Holidays may be observed differently across these divisions. For example:
using mitoSoft.Holidays.Germany;
// Get all German holidays for a specific year
var germanHolidays = new Holidays();
var holidays2024 = germanHolidays.GetHolidays(2024);
// Check if a date is a holiday in a specific Bundesland
var date = new DateTime(2024, 1, 6); // Epiphany
bool isHolidayInBayern = germanHolidays.IsHoliday(date, Bundeslaender.Bayern); // true
bool isHolidayInBerlin = germanHolidays.IsHoliday(date, Bundeslaender.Berlin); // false
// Using extension methods
bool isHoliday = date.IsHoliday(germanHolidays, Bundeslaender.Bayern);
var holiday = date.GetHoliday(germanHolidays);
using mitoSoft.Holidays;
// Get holidays by country code
var germanHolidays = HolidaysHelper.GetHolidays("de");
var usHolidays = HolidaysHelper.GetHolidays("us");
var date = new DateTime(2024, 7, 4);
bool isUSHoliday = usHolidays.IsHoliday(date, "Federal");
using mitoSoft.Holidays.UnitedStates;
var usHolidays = new Holidays();
// Check federal holidays
var independenceDay = new DateTime(2024, 7, 4);
bool isFederalHoliday = usHolidays.IsHoliday(independenceDay, States.Federal);
// Get all holidays for a specific date
var allHolidaysOnDate = usHolidays.GetHolidays(independenceDay);
// Check state-specific holidays
var date = new DateTime(2024, 10, 14); // Columbus Day / Indigenous Peoples' Day
bool isHolidayInCalifornia = usHolidays.IsHoliday(date, States.California);
using System.Globalization;
var germanHolidays = new mitoSoft.Holidays.Germany.Holidays();
var christmas = new DateTime(2024, 12, 25);
var holiday = germanHolidays.GetHoliday(christmas);
// Get localized name
string nameInGerman = holiday.GetDisplayName(new CultureInfo("de-DE"));
string nameInEnglish = holiday.GetDisplayName(new CultureInfo("en-US"));
// Get holiday properties
DateTime originalDate = holiday.OriginalDate;
DateTime observedDate = holiday.ObservedDate;
bool isFixed = holiday.IsFixedDate;
// Get administrative divisions where it's observed
var divisions = holiday.GetAdministrativeDivisions();
National Holidays:
Regional Holidays:
Federal Holidays:
To add support for a new country:
using System;
namespace mitoSoft.Holidays.YourCountry
{
[Flags]
public enum Regions : uint
{
None = 0,
Region1 = 1 << 0,
Region2 = 1 << 1,
Region3 = 1 << 2,
// Add more regions...
National = Region1 | Region2 | Region3
}
}
namespace mitoSoft.Holidays.YourCountry
{
public sealed class Holiday : Holiday<Regions>
{
public Holiday(string name, DateTime date, bool isFixedDate, Regions regions)
: base(name, date, date, isFixedDate, regions)
{
}
public override bool IsHoliday(Regions region)
=> this.AdministrativeDivisions.HasFlag(region);
}
}
using System;
using System.Collections.Generic;
namespace mitoSoft.Holidays.YourCountry
{
public sealed class Holidays : Holidays<Regions>
{
public Holidays() : base("Your Country Name")
{
}
public override IEnumerable<Holiday<Regions>> GetHolidays(int year)
{
yield return new Holiday("NewYear", new DateTime(year, 1, 1), true, Regions.National);
// Add more holidays...
}
}
}
HolidaysHelper.RegisterHolidays("yc", new YourCountry.Holidays());
The library includes a built-in EasterSunday calculator that uses the Oudin (1940) algorithm:
var easterSunday = EasterSunday.Get(2024); // March 31, 2024
var goodFriday = easterSunday.AddDays(-2);
var easterMonday = easterSunday.AddDays(1);
var ascension = easterSunday.AddDays(39);
var pentecost = easterSunday.AddDays(49);
IHoliday - Represents a single holidayIHolidays - Represents a collection of holidays for a countryHoliday<T> - Base class for holiday implementationsHolidays<T> - Base class for country holiday collectionsHolidaysHelper - Static helper for managing multiple countriesGetHoliday(DateTime, IHolidays) - Get holiday on a specific dateIsHoliday(DateTime, IHolidays, string) - Check if date is a holidayThe library supports multiple languages through resource files. Holiday names can be localized:
var holiday = germanHolidays.GetHoliday(new DateTime(2024, 12, 25));
// Get German name
string german = holiday.GetDisplayName(new CultureInfo("de-DE")); // "1. Weihnachtsfeiertag"
// Get English name
string english = holiday.GetDisplayName(new CultureInfo("en-US")); // "Christmas Day"
For more comprehensive examples, see the test classes in the .
var germanHolidays = new mitoSoft.Holidays.Germany.Holidays();
for (int year = 2020; year <= 2025; year++)
{
var easterSunday = EasterSunday.Get(year);
Console.WriteLine($"Easter {year}: {easterSunday:yyyy-MM-dd}");
}
var usHolidays = new mitoSoft.Holidays.UnitedStates.Holidays();
var californiaHolidays = usHolidays.GetHolidays(2024)
.Where(h => h.IsHoliday(States.California))
.OrderBy(h => h.ObservedDate);
foreach (var holiday in californiaHolidays)
{
Console.WriteLine($"{holiday.ObservedDate:yyyy-MM-dd} - {holiday.GetDisplayName()}");
}
// The library tracks both OriginalDate and ObservedDate
// You can implement custom weekend adjustment logic as needed
var holiday = usHolidays.GetHoliday(new DateTime(2024, 7, 4));
DateTime originalDate = holiday.OriginalDate; // 2024-07-04
DateTime observedDate = holiday.ObservedDate; // 2024-07-04
Contributions are welcome! Please feel free to submit pull requests or open issues for:
This project is licensed under the terms specified in the file.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on mitoSoft.Holidays:
| Package | Downloads |
|---|---|
|
mitoSoft.DailyTimers.Core
A library for lightweight daily and weekly timer handling in C# |
|
|
DoenaSoft.PillRefresh
A .NET library for calculating medication supply duration and generating calendar reminders with automatic weekend and holiday avoidance. Supports multiple target frameworks and generates iCalendar (.ics) files compatible with Outlook, Google Calendar, and other applications. |
This package is not used by any popular GitHub repositories.