Calendrical. Reform. Japan
(Calendrical v1.1.0)
Copy Markdown
A composite calendar that tracks the historical calendar in use in Japan.
Unlike the European reforms, Japan did not move from the Julian calendar to
the Gregorian calendar. Before 1873 Japan used the Tenpō lunisolar calendar
(Calendrical.LunarJapanese); it adopted the Gregorian calendar as part of the
Meiji reforms. This makes Calendrical.Reform.Japan a good example of a
composite that splices a lunisolar calendar with a solar one.
The Gregorian side uses Calendrical.Japanese rather than
Calendrical.Gregorian, so post-reform dates carry Japanese era years
(Meiji, Taishō, Shōwa, Heisei, Reiwa) when localized — 1 January 1873 is
Meiji 6.
Transitions
(base) — the Japanese lunisolar calendar (
Calendrical.LunarJapanese).1873-01-01 — Japan adopts the Gregorian calendar (as
Calendrical.Japanese). The last lunisolar day, Meiji 5, month 12, day 2 (31 December 1872 in the Gregorian calendar), is followed directly by 1 January 1873. No physical days are skipped — only the remainder of the lunisolar month is dropped.
Because Calendrical.LunarJapanese numbers years continuously from the Taika
era (645 CE), pre-reform dates carry that year number rather than an era-based
year such as "Meiji 5".
Examples
# The physical day before the reform, in the lunisolar calendar
iex> Date.convert!(~D[1873-01-01 Calendrical.Reform.Japan], Calendrical.Gregorian)
~D[1873-01-01 Calendrical.Gregorian]
iex> Date.convert!(~D[1873-01-01 Calendrical.Gregorian], Calendrical.Reform.Japan)
~D[1873-01-01 Calendrical.Reform.Japan]Reference
See Calendrical.Reform for the reform dates of other territories and the
sources they are drawn from.
Summary
Functions
Identifies that the calendar is month based.
Identify the base calendar for a given date.
Identify the base calendar for a given iso_days.
Returns the calendar year as displayed on rendered calendars.
Defines the CLDR calendar type for this calendar.
Returns the cyclic year.
Returns {year, month, day} calculated from the number of
iso_days.
Returns the number of days since the calendar epoch for the
given year-month-day.
Calculates the day and era for the given date.
Calculates the day of the week for the given date.
Calculates the day of the year for the given date.
Returns the number of days in the given month.
Returns the number of days in the given year/month.
Returns the number of days in a week.
Returns the number of days in the given year.
Returns the extended year.
Calculates the ISO week of the year for the given date.
Returns whether the given year is a leap year, in the context of the calendar in effect on the first day of that year.
Returns a Date.Range representing a given month of a year.
Calculates the month of the year for the given date.
Converts a Calendar.iso_days/0 to the datetime form for
this calendar.
Returns the Calendar.iso_days/0 form of the specified
datetime.
Returns the number of periods in the given year.
Adds an increment number of :months or :quarters to the
given year-month-day. Delegates to whichever base calendar is
in effect on the input date.
Returns a Date.Range representing a given quarter of a year.
Calculates the quarter of the year (1..4) for the given date.
Returns the related Gregorian year.
Shifts a date by the given duration.
Determines if the date given is valid according to this calendar.
Returns a Date.Range representing a given week of a year.
Composite calendars do not define week-of-month.
Calculates the week of the year for the given date.
Returns the number of weeks in the given year (in the context of the calendar that starts the year).
Returns a Date.Range representing a given year.
Calculates the year and era from the given year, month,
and day. The result is in the context of the calendar in
effect on that date.
Types
Functions
Identifies that the calendar is month based.
This may not always be true for all dates in a composite calendar but only a single value per calendar is supported.
Identify the base calendar for a given date.
This function derives the calendar we delegate to for a given date based upon the configuration.
Identify the base calendar for a given iso_days.
@spec calendar_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.year()
Returns the calendar year as displayed on rendered calendars.
Defines the CLDR calendar type for this calendar.
This type is used in support of Calendrical.localize/3.
@spec cyclic_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.year()
Returns the cyclic year.
Returns {year, month, day} calculated from the number of
iso_days.
Returns the number of days since the calendar epoch for the
given year-month-day.
Calculates the day and era for the given date.
Calculates the day of the week for the given date.
Calculates the day of the year for the given date.
Returns the number of days in the given month.
Composite calendars cannot answer this without a year so the
default implementation returns {:error, :undefined}.
Returns the number of days in the given year/month.
Returns the number of days in a week.
Returns the number of days in the given year.
@spec extended_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.year()
Returns the extended year.
Calculates the ISO week of the year for the given date.
Returns whether the given year is a leap year, in the context of the calendar in effect on the first day of that year.
Returns a Date.Range representing a given month of a year.
Calculates the month of the year for the given date.
Converts a Calendar.iso_days/0 to the datetime form for
this calendar.
@spec naive_datetime_to_iso_days( Calendar.year(), Calendar.month(), Calendar.day(), Calendar.hour(), Calendar.minute(), Calendar.second(), Calendar.microsecond() ) :: Calendar.iso_days()
Returns the Calendar.iso_days/0 form of the specified
datetime.
Returns the number of periods in the given year.
Adds an increment number of :months or :quarters to the
given year-month-day. Delegates to whichever base calendar is
in effect on the input date.
Returns a Date.Range representing a given quarter of a year.
Calculates the quarter of the year (1..4) for the given date.
Shifts a date by the given duration.
Determines if the date given is valid according to this calendar.
Returns a Date.Range representing a given week of a year.
Not all base calendars define weeks; the result depends on the calendar in effect on 1 January of the given year.
Composite calendars do not define week-of-month.
Calculates the week of the year for the given date.
Returns the number of weeks in the given year (in the context of the calendar that starts the year).
Returns a Date.Range representing a given year.
@spec year_of_era(year(), month(), day()) :: {year(), era :: non_neg_integer()}
Calculates the year and era from the given year, month,
and day. The result is in the context of the calendar in
effect on that date.