Mamemaki.HolidayJp 1.0.4

dotnet add package Mamemaki.HolidayJp --version 1.0.4                
NuGet\Install-Package Mamemaki.HolidayJp -Version 1.0.4                
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="Mamemaki.HolidayJp" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mamemaki.HolidayJp --version 1.0.4                
#r "nuget: Mamemaki.HolidayJp, 1.0.4"                
#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 Mamemaki.HolidayJp as a Cake Addin
#addin nuget:?package=Mamemaki.HolidayJp&version=1.0.4

// Install Mamemaki.HolidayJp as a Cake Tool
#tool nuget:?package=Mamemaki.HolidayJp&version=1.0.4                

Mamemaki.HolidayJp

Actions Status NuGet Badge License

.NET library for Calculate Japan public Holidays

  • Purely holiday calculator.
  • No dataset or other external resources used
  • No dependencies
  • Support 1955 to 2150 years range
  • Tested with syukujitsu.csv

Install

Install with NuGet:

PM> Install-Package Mamemaki.HolidayJp

Example Usage

Calculate public holidays of a year

var holidays = HolidayCalculator.GetHolidaysInYear(2019);
foreach (var holiday in holidays)
{
    Console.WriteLine($"[{holiday.Date.ToString("yyyy/MM/dd")}] {holiday.Name}");
}

Get public holidays for a date range

var jphol = new JapanHoliday();
var startDate = new DateTime(2016, 5, 1);
var endDate = new DateTime(2018, 5, 31);
var holidays = jphol.GetHolidaysInDateRange(startDate, endDate);
foreach (var holiday in holidays)
{
    Console.WriteLine($"[{holiday.Date.ToString("yyyy/MM/dd")}] {holiday.Name}");
}

Get public holiday for a date

var jphol = new JapanHoliday();
var date = new DateTime(2019, 1, 1);
var holiday = jphol.GetHoliday(date);
if (holiday != null)
{
    Console.WriteLine($"[{holiday.Date.ToString("yyyy/MM/dd")}] {holiday.Name}");
}
else
{
    Console.WriteLine($"{date.ToString("yyyy/MM/dd")} is not public holiday");
}

Check if a date is a weekend/weekday/holiday/workingday day

var jphol = new JapanHoliday();
var date = new DateTime(2019,11,8);
Console.WriteLine($"{date.ToString("yyyy/MM/dd")} is {(jphol.IsWeekday(date) ? "weekday" : "not weekday")}");
Console.WriteLine($"{date.ToString("yyyy/MM/dd")} is {(jphol.IsWeekend(date) ? "weekend" : "not weekend")}");
Console.WriteLine($"{date.ToString("yyyy/MM/dd")} is {(jphol.IsHoliday(date) ? "holiday" : "not holiday")}");
Console.WriteLine($"{date.ToString("yyyy/MM/dd")} is {(jphol.IsWorkingDay(date) ? "workingday" : "not workingday")}");
Console.WriteLine($"{date.ToString("yyyy/MM/dd")}'s next workingday is {jphol.NextWorkingDay(date).ToString("yyyy/MM/dd")}");
Console.WriteLine($"{date.ToString("yyyy/MM/dd")}'s previous workingday is {jphol.PreviousWorkingDay(date).ToString("yyyy/MM/dd")}");

API References

Holiday object

Name Description
Date Date of the holiday.
Kind Kind of the holiday. see HolidayKind.
Name Name of the holiday in Japanese.
GlobalName Name of the holiday in English.

HolidayKind enum

Name Description
National 国民の祝日
Citizens 国民の休日
Substitute 振替休日

HolidayCalculator class

This class is to calculate japan holidays. it has only one public method GetHolidaysInYear(int year) that calculates holidays in the specified year.

JapanHoliday class

This class has many utility methods for Japan holidays. And calculated results are cached so calculation does not execute twice.

Methods
IEnumerable<Holiday> GetHolidaysInYear(int year)

Get holidays in the specified year.

IEnumerable<Holiday> GetHolidaysInDateRange(DateTime dateStart, DateTime dateEnd)

Get public holidays for a date range.

Holiday GetHoliday(DateTime date)

Get holidays in the specified year.

bool IsHoliday(DateTime date)

Check if a date is a public holiday.

bool IsWeekday(DateTime date)

Check if a date is a weekday. weekday means Monday to Friday.

bool IsWeekend(DateTime date)

Check if a date is a weekend weekend means Saturday or Sunday.

bool IsWorkingDay()

Check if today is a working day. working day means Monday to Friday and does not holiday.

bool IsWorkingDay(DateTime date)

Check if a date is a working day. working day means Monday to Friday and does not holiday.

DateTime NextWorkingDay(DateTime date)

Get next working day of the specified date. working day means Monday to Friday and does not holiday.

DateTime PreviousWorkingDay(DateTime date)

Get previous working day of the specified date. working day means Monday to Friday and does not holiday.

Thanks

内閣府ホームページ

https://zariganitosh.hatenablog.jp/entry/20140929/japanese_holiday_memo

https://www.pahoo.org/e-soul/webtech/php02/php02-27-01.shtm

https://www.atmarkit.co.jp/ait/articles/1507/22/news024.html

License

Apache 2.0

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework 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 tizen40 was computed.  tizen60 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.
  • .NETStandard 2.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.4 153 6/26/2024
1.0.3 860 6/15/2023
1.0.2 585 7/20/2021
1.0.1 513 12/11/2019
1.0.0 2,189 11/28/2019