Chinese lunisolar dates, with numbered months and an explicit leap-month flag.
from_date/1 and to_date/1 convert the civil dates in supported_range/0.
An aware datetime is an instant and uses the date at UTC+08:00 (Beijing
standard time). A naive datetime already supplies a civil date. Conversion
uses the month starts and lengths shipped with DayEx.
Summary
Functions
Formats a lunar date in simplified Chinese, for example 甲辰年正月初一.
Converts a Gregorian date or datetime to a Chinese lunar date.
Returns the lunar year's stem and branch (干支), changing on Chinese New Year.
Returns the inclusive range of supported Gregorian civil dates.
Converts a lunar date to a native Gregorian date.
Returns the lunar year's Chinese zodiac animal in simplified Chinese.
Types
Functions
Formats a lunar date in simplified Chinese, for example 甲辰年正月初一.
@spec from_date(Date.t() | NaiveDateTime.t() | DateTime.t()) :: {:ok, t()} | {:error, :out_of_range}
Converts a Gregorian date or datetime to a Chinese lunar date.
Returns the lunar year's stem and branch (干支), changing on Chinese New Year.
@spec supported_range() :: Date.Range.t()
Returns the inclusive range of supported Gregorian civil dates.
Converts a lunar date to a native Gregorian date.
Returns {:error, :invalid_lunar_date} for impossible fields, such as the
30th of a short month or a leap month that does not exist in the given year.
Dates outside the published interval return {:error, :out_of_range}.
Returns the lunar year's Chinese zodiac animal in simplified Chinese.