Skip to content

zwei222/JpCalendar

Repository files navigation

JpCalendar

NuGet GitHub Actions

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.

Features

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.

Quick Start

Install the NuGet package as follows.

dotnet add package JpCalendar

Usage

Era

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日

National holiday

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
山の日

Rokuyo

Get the "Rokuyo" corresponding to the date passed to GetRokuyo(date).

private string GetRokuyo(DateTime date)
{
    return Calendar.GetRokuyo(date);
}
# date <- 2023-08-07
友引

Examples

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.

Era

image

National holiday

image

image

Rokuyo

image

image

Author

@zwei_222

License

This software is released under the MIT License, see LICENSE.

Releases

No releases published

Packages

No packages published

Languages