CelestialCalendar 1.0.0 · unreleased development @ 67a7c4c79a4a4a6aa7e703c9e6f0039ae34bee82
Loading...
Searching...
No Matches
calendar::lunar::algo2 Namespace Reference

Classes

struct  LunarMonth
 The metadata of a lunar month. More...
struct  LunarMonthGenerator
 Generate lunar-month metadata after a JDE(TT). 生成给定 JDE(TT) 后的阴历月元数据。 More...
struct  LunarYearContext
 The raw lunar year information, can be processed to LunarYear. More...

Typedefs

using LunarYear
using LunarMonthChunk
 A chunk of lunar months.

Functions

auto jde_to_utc8 (const double jde) -> calendar::Datetime
 Convert a JDE (TT) moment to fixed-offset east-eight civil time for lunar date assignment. 把 JDE(TT)时刻转换为固定东八区民用时间,用于确定阴历日期。
auto calc_lunar_month_chunks (int32_t year) -> std::pair< LunarMonthChunk, LunarMonthChunk >
 Calculate the lunar month chunks for the given year.
auto leap_month_in_chunk (const LunarMonthChunk &chunk) -> std::optional< int32_t >
 Get the leap month in the given chunk.
auto calc_lunar_year_start_moment (const LunarMonthChunk &chunk, std::optional< int32_t > leap_month) -> calendar::Datetime
 Get the start moment of the lunar year.
auto create_lunar_year_context (int32_t year) -> LunarYearContext
 Create a LunarYearContext for the given year, which basically contains the month info, including leap month.
auto calc_lunar_year (int32_t year) -> LunarYear
 Calculate the lunar year information for the given year. 计算给定年份的阴历年信息。
auto get_info_for_year (const int32_t year) -> LunarYear
 Get the lunar year information for the given year, using cache. 返回给定年份的阴历年信息。使用缓存。
auto bounds () -> const common::AlgoBounds &
 The bounds of the algorithm, i.e. the supported range of lunar and Gregorian dates.

Variables

constexpr int32_t START_YEAR
 The first supported lunar year.
constexpr int32_t END_YEAR
 The last supported lunar year.

Typedef Documentation

◆ LunarMonthChunk

A chunk of lunar months.

A chunk is defined as a contiguous sequence of lunar months, from 11th month in a year (inclusive), to 11th month in the next year (exclusive).

◆ LunarYear

Function Documentation

◆ bounds()

auto calendar::lunar::algo2::bounds ( ) ->constcommon::AlgoBounds &
inlinenodiscard

The bounds of the algorithm, i.e. the supported range of lunar and Gregorian dates.

Returns
The lazily computed bounds.
Note
#67: function-local static, not a namespace-scope variable — the latter computes at static-init time, i.e. runs the whole astro pipeline (VSOP87D + ELP2000 + nutation) while the shared library is still being loaded, where an escaping exception would terminate the host before main.

◆ calc_lunar_month_chunks()

auto calendar::lunar::algo2::calc_lunar_month_chunks ( int32_t year) ->std::pair< LunarMonthChunk, LunarMonthChunk >
inlinenodiscard

Calculate the lunar month chunks for the given year.

Parameters
yearThe Lunar year.
Returns
The lunar month chunks. The first chunk is from 11th month in the previous year to 11th month in the current year. The second chunk is from 11th month in the current year to 11th month in the next year.

◆ calc_lunar_year()

auto calendar::lunar::algo2::calc_lunar_year ( int32_t year) ->LunarYear
inlinenodiscard

Calculate the lunar year information for the given year. 计算给定年份的阴历年信息。

Attention
The input year should be in the range of [START_YEAR, END_YEAR].
Parameters
yearThe Lunar year. 阴历年份。
Returns
The lunar year information. 阴历年信息。
See also
https://ytliu0.github.io/ChineseCalendar/rules_simp.html

◆ calc_lunar_year_start_moment()

auto calendar::lunar::algo2::calc_lunar_year_start_moment ( const LunarMonthChunk & chunk,
std::optional< int32_t > leap_month )->calendar::Datetime
inlinenodiscard

Get the start moment of the lunar year.

Parameters
chunkThe chunk of lunar months.
leap_monthThe index of the leap month in the given chunk. std::nullopt if there is no leap month.
Returns
The start moment of the lunar year.

◆ create_lunar_year_context()

auto calendar::lunar::algo2::create_lunar_year_context ( int32_t year) ->LunarYearContext
inlinenodiscard

Create a LunarYearContext for the given year, which basically contains the month info, including leap month.

Parameters
yearThe year to create the context for.
Returns
The LunarYearContext for the given year.

◆ get_info_for_year()

auto calendar::lunar::algo2::get_info_for_year ( const int32_t year) ->LunarYear
inlinenodiscard

Get the lunar year information for the given year, using cache. 返回给定年份的阴历年信息。使用缓存。

Parameters
yearThe Lunar year. 阴历年份。
Returns
The lunar year information. 阴历年信息。
See also
https://ytliu0.github.io/ChineseCalendar/rules_simp.html

◆ jde_to_utc8()

auto calendar::lunar::algo2::jde_to_utc8 ( const double jde) ->calendar::Datetime
inlinenodiscard

Convert a JDE (TT) moment to fixed-offset east-eight civil time for lunar date assignment. 把 JDE(TT)时刻转换为固定东八区民用时间,用于确定阴历日期。

Parameters
jdeThe julian ephemeris day number, which is based on TT. 基于 TT 的儒略历书日。
Returns
The datetime at the fixed UTC+8 offset. 固定 UTC+8 偏移下的日期时间。

Before 1972, jde_to_utc deliberately uses UT1 as a proxy because historical UTC is not modelled. From 1972 through the final announced leap-second step it uses the ΔAT table; beyond that table, ΔAT is held at 37 s. The fixed eight-hour offset is applied after that three-era conversion.

Note
The result assigns a calendar-date label; it is not an instant carrying a time zone. 返回值用于确定日历日期标记;它不是携带时区的时刻。
Leap seconds step at UTC midnight, i.e. 08:00 in UTC+8 (#84) — the non-invertible second of leap_second::tt_to_utc never lands on a civil-day boundary here. 闰秒在 UTC 午夜、即 UTC+8 的 08:00 跳变,因此 leap_second::tt_to_utc 的不可逆一秒不会落在这里的民用日边界上。

◆ leap_month_in_chunk()

auto calendar::lunar::algo2::leap_month_in_chunk ( const LunarMonthChunk & chunk) ->std::optional< int32_t >
inlinenodiscard

Get the leap month in the given chunk.

Parameters
chunkThe chunk of lunar months.
Returns
The index of the leap month in the given chunk. std::nullopt if there is no leap month.

Variable Documentation

◆ END_YEAR

int32_t calendar::lunar::algo2::END_YEAR
inlineconstexpr

The last supported lunar year.

◆ START_YEAR

int32_t calendar::lunar::algo2::START_YEAR
inlineconstexpr

The first supported lunar year.