.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 with NuGet:
PM> Install-Package Mamemaki.HolidayJp
var holidays = HolidayCalculator.GetHolidaysInYear(2019);
foreach (var holiday in holidays)
{
Console.WriteLine($"[{holiday.Date.ToString("yyyy/MM/dd")}] {holiday.Name}");
}
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}");
}
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");
}
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")}");
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. |
Name | Description |
---|---|
National |
国民の祝日 |
Citizens |
国民の休日 |
Substitute |
振替休日 |
This class is to calculate japan holidays. it has only one public method GetHolidaysInYear(int year)
that calculates holidays in the specified year.
This class has many utility methods for Japan holidays. And calculated results are cached so calculation does not execute twice.
Get holidays in the specified year.
Get public holidays for a date range.
Get holidays in the specified year.
Check if a date is a public holiday.
Check if a date is a weekday. weekday means Monday to Friday.
Check if a date is a weekend weekend means Saturday or Sunday.
Check if today is a working day. working day means Monday to Friday and does not holiday.
Check if a date is a working day. working day means Monday to Friday and does not holiday.
Get next working day of the specified date. working day means Monday to Friday and does not holiday.
Get previous working day of the specified date. working day means Monday to Friday and does not holiday.
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