CalendarManagement 1.0.1

dotnet add package CalendarManagement --version 1.0.1
                    
NuGet\Install-Package CalendarManagement -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="CalendarManagement" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CalendarManagement" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CalendarManagement" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CalendarManagement --version 1.0.1
                    
#r "nuget: CalendarManagement, 1.0.1"
                    
#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.
#:package CalendarManagement@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CalendarManagement&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CalendarManagement&version=1.0.1
                    
Install as a Cake Tool

Calendar Management

C# library for handling workdays and holidays

  • Usage

The package can be used to determine which days are holidays and which are workdays. It calculates moving holidays regularly if necessary. It can create a list of holidays and workdays in a given interval.

The package uses below 2 datatype:<br> For the fix holiday:<br>

    public class FixHoliday
    {
        public int Month {get; set;}
        public int Day {get; set;}
    }

It is represent the fix holidays. Before instantiation, you need to compile a list of fixed holidays and pass it to the constructor. See examples below.

And for the moved working days:<br>

    public class MovedWorkDays
    {
        public DateOnly MovedWorkday { get; set; }
        public DateOnly MovedTo { get; set; }
    }

This list must also be constructed before instantiation if you want to use it. It is not mandatory to pass it to the constructor during instantiation.

  1. You should create a list for the fix holidays.
private List<FixHoliday> _fixHolidays = new();

FixHoliday newYear = new FixHoliday { Month = 1, Day = 1 };
_fixHolidays.Add(newYear);
FixHoliday revolution = new FixHoliday { Month = 3, Day = 15 };
_fixHolidays.Add(revolution);
FixHoliday labourDay = new FixHoliday { Month = 5, Day = 1 };
_fixHolidays.Add(labourDay);
FixHoliday stateFoundingDay = new FixHoliday { Month = 8, Day = 20 };
_fixHolidays.Add(stateFoundingDay);
FixHoliday republicDay = new FixHoliday { Month = 10, Day = 23 };
_fixHolidays.Add(republicDay);
FixHoliday helloween = new FixHoliday { Month = 11, Day = 1 };
_fixHolidays.Add(helloween);
FixHoliday xmas1 = new FixHoliday { Month = 12, Day = 25 };
_fixHolidays.Add(xmas1);
FixHoliday xmas2 = new FixHoliday { Month = 12, Day = 26 };
_fixHolidays.Add(xmas2);
FixHoliday silvester = new FixHoliday { Month = 12, Day = 31 };
_fixHolidays.Add(silvester);
  1. You should create a list for the moved workdays, if necessary.
List<MovedWorkDays> movedWorkdays = new List<MovedWorkDays>();
            
MovedWorkDays mwd = new MovedWorkDays()
{ 
    MovedWorkday = new DateOnly(2025,5,2),
    MovedTo = new DateOnly(2025,5,17)
};
movedWorkdays.Add(mwd);
MovedWorkDays mwd2 = new MovedWorkDays()
{
    MovedWorkday = new DateOnly(2025, 10, 24),
    MovedTo = new DateOnly(2025, 10, 18)
};
movedWorkdays.Add(mwd2);

MovedWorkDays mwd3 = new MovedWorkDays()
{
    MovedWorkday = new DateOnly(2025, 12, 24),
    MovedTo = new DateOnly(2025, 12, 13)
};
movedWorkdays.Add(mwd3);

  1. You should create a list for the additional workdays, if necessary.
List<DateOnly> additionalWorkdays = new List<DateOnly>()
{ 
    new DateOnly(2025,03,08),
    new DateOnly(2025,03,22),
};

  1. Create an instance
CalendarMgmnt c = new CalendarMgmnt(fixHolidays: _fixHolidays, movedWorkDays: movedWorkdays, additionalWorkdays: additionalWorkdays);

// For Hungarian users, in this case the constuctor build automatically the list of fix holidays.
CalendarMgmnt c = new CalendarMgmnt(fixHolidays: null, movedWorkDays: movedWorkdays, additionalWorkdays: additionalWorkdays);
  1. Methods
CalendarMgmnt c = new CalendarMgmnt(_fixHolidays, movedWorkdays);
// movedWorkdays is optional.

CalendarMgmnt hun = new CalendarMgmnt(movedWorkdays);
// For Hungarian users, in this case the constuctor build automatically the list of fix holidays.
// movedWorkdays is optional.

// Date of Easter Monday
Console.WriteLine(c.GetEasterMonday(2024)); // -> 2024.04.01

DateOnly start = new DateOnly(2025, 3, 1);
DateOnly end = new DateOnly(2025, 3, 31);

var workdays = c.GetWorkdays(start, end); // List of workdays
var holidays = c.GetHolidays(start, end); // List of holidays

Console.WriteLine(c.CountDays(start, end)); // -> (21,10) Number of workdays and holidays

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 194 7/18/2025
1.0.0 203 7/1/2025