This library is for processing related to the Japanese calendar.
Processing related to Japanese national holidays and the era name based on the contents listed in the following URLs and the CSV files that can be downloaded.
The features of this library are described below.
- A function to obtain the era number (Japanese calendar) based on a given date.
- A function to obtain the "Rokuyo" based on a given date.
- A function to retrieve the name of a Japanese holiday based on a given date.
Install the NuGet package as follows.
dotnet add package JpCalendar
Get the Japanese calendar name corresponding to the date passed to GetEra(date)
.
private string ToJapaneseString(DateTime date, string format)
{
return $"{Calendar.GetEra(date).Name}{date.ToString(format, Calendar.JapaneseCultureInfo)}";
}
# date <- 2023-08-07
令和5年08月07日
Get the name of the holiday corresponding to the date passed to GetNationalHolidayName(date)
. Returns null
if the date is not a national holiday.
private string GetJapaneseNationalHoliday(DateTime date)
{
return Calendar.GetNationalHolidayName(date);
}
# date <- 2023-08-11
山の日
Get the "Rokuyo" corresponding to the date passed to GetRokuyo(date)
.
private string GetRokuyo(DateTime date)
{
return Calendar.GetRokuyo(date);
}
# date <- 2023-08-07
友引
In addition to the library, the ASP.NET Core Web API project exists in this repository. By running the Web API project, it is possible to see the library in action on the Swagger UI.
This software is released under the MIT License, see LICENSE.