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

Classes

 Specialize AlgoMetadata for Algo::ALGO_1. More...
 Specialize AlgoMetadata for Algo::ALGO_2. More...
 Specialize AlgoMetadata for Algo::ALGO_3. More...
struct  LunarYear
 Information of the lunar year. 阴历年信息。 More...
struct  TraditionalMonth
 A lunar month in traditional numbering: month number (1-12) plus a leap flag. 传统编号的阴历月:月份 (1-12) 加闰月标记。 More...
struct  AlgoBounds
 The bounds of the algorithm. More...
 The type trait for the lunar algorithm, expected specializations in every algorithm implementation. More...

Typedefs

using year_month_day

Enumerations

enum class  Algo : uint8_t { ALGO_1 , ALGO_2 , ALGO_3 }
 Algorithm version. More...

Functions

auto parse_lunar_year (int32_t year, uint32_t encoded) -> LunarYear
 Parse the encoded lunar year information for the given year. 返回给定年份的阴历年信息。
auto month_position (const LunarYear &info, const uint8_t month, const bool is_leap) -> std::optional< uint8_t >
 Translate a traditionally-numbered lunar month to its 1-based position in info.month_lengths. 把传统编号的阴历月翻译成 info.month_lengths 里的位置序号(从 1 起)。
auto month_at_position (const LunarYear &info, const uint8_t position) -> std::optional< TraditionalMonth >
 Translate a 1-based position in info.month_lengths back to traditional numbering. 把 info.month_lengths 里的位置序号(从 1 起)翻译回传统编号。
template<typename Func>
requires std::invocable<const Func&, int32_t> and std::convertible_to<std::invoke_result_t<const Func&, int32_t>, LunarYear>
auto calc_bounds (const int32_t start_lunar_year, const int32_t end_lunar_year, const Func &algo_f) -> AlgoBounds
 Calculate the bounds of the lunar algorithm.

Typedef Documentation

◆ year_month_day

Enumeration Type Documentation

◆ Algo

enum class calendar::lunar::common::Algo : uint8_t
strong

Algorithm version.

Enumerator
ALGO_1 
ALGO_2 
ALGO_3 

Function Documentation

◆ calc_bounds()

template<typename Func>
requires std::invocable<const Func&, int32_t> and std::convertible_to<std::invoke_result_t<const Func&, int32_t>, LunarYear>
auto calendar::lunar::common::calc_bounds ( const int32_t start_lunar_year,
const int32_t end_lunar_year,
const Func & algo_f )->AlgoBounds
inlinenodiscard

Calculate the bounds of the lunar algorithm.

◆ month_at_position()

auto calendar::lunar::common::month_at_position ( const LunarYear & info,
const uint8_t position )->std::optional< TraditionalMonth >
inlinenodiscard

Translate a 1-based position in info.month_lengths back to traditional numbering. 把 info.month_lengths 里的位置序号(从 1 起)翻译回传统编号。

Parameters
infoThe lunar year. 阴历年信息。
positionThe 1-based position. 位置序号(从 1 起)。
Returns
The traditionally-numbered month; std::nullopt if position is out of range. 传统编号的月;position 越界时返回 std::nullopt。

◆ month_position()

auto calendar::lunar::common::month_position ( const LunarYear & info,
const uint8_t month,
const bool is_leap )->std::optional< uint8_t >
inlinenodiscard

Translate a traditionally-numbered lunar month to its 1-based position in info.month_lengths. 把传统编号的阴历月翻译成 info.month_lengths 里的位置序号(从 1 起)。

Parameters
infoThe lunar year. 阴历年信息。
monthThe traditional month number (1-12). 传统编号 (1-12)。
is_leapWhether the month is the leap month. 是否闰月。
Returns
The 1-based position; std::nullopt if month is out of range, or if is_leap does not match the year's actual leap month (including leap-less years). 位置序号(从 1 起);month 越界,或 is_leap 与该年实际闰月不符(含无闰月年)时返回 std::nullopt。

◆ parse_lunar_year()

auto calendar::lunar::common::parse_lunar_year ( int32_t year,
uint32_t encoded )->LunarYear
inlinenodiscard

Parse the encoded lunar year information for the given year. 返回给定年份的阴历年信息。

Parameters
yearThe lunar year. 阴历年份。
encodedThe encoded lunar year information. 阴历年信息的编码。
Returns
The lunar year information. 阴历年信息。