Converts between gregorian date and lunar date. 将公历日期和阴历日期进行转换。
More...
#include <converter.hpp>
template<
common::Algo algo>
struct calendar::lunar::converter::Converter< algo >
Converts between gregorian date and lunar date. 将公历日期和阴历日期进行转换。
- Template Parameters
-
| algo | The algorithm to use. 使用的算法。 |
- Note
- Lunar months are positional in this interface: the month of a lunar year_month_day is the 1-based index into the year's month sequence (12 or 13 entries), where a leap month takes its own position — not the traditional month number, which this interface cannot express (there is no leap flag). E.g. lunar 2023 (leap 2nd month): month 3 is the leap 2nd month, and the traditional 3rd month is month 4. Translate with common::month_position / common::month_at_position (#130). 本接口的阴历月是位置序号:阴历 year_month_day 的「月」是该年 12/13 个月里 从 1 起的位置,闰月独占一位——不是传统编号(本接口没有闰月标记,表达不了)。 例:2023 年闰二月,月 3 = 闰二月,传统三月 = 月 4。与传统编号的互转见 common::month_position / common::month_at_position(#130)。
-
Gregorian inputs and outputs are calendar-date labels on the selected algorithm's basis, not instants. See algo1.hpp, algo2.hpp, and algo3.hpp for their date bases. 公历输入和输出是所选算法基准上的日期标记,不是时刻。 各算法的日期基准见 algo1.hpp、algo2.hpp 和 algo3.hpp。
◆ AlgoMetadata
◆ gregorian_to_lunar()
Converts gregorian date to lunar date. 将公历日期转换为阴历日期。
- Parameters
-
| gregorian_date | The gregorian date. 公历日期。 |
- Returns
- The optional lunar date; its month is the positional index (see Converter's note). 阴历日期(optional);其「月」是位置序号(见 Converter 的注)。
- Attention
- The input date should be in the supported range. 输入的日期需要在所支持的范围内。
-
std::nullopt is returned if the input date is invalid. No exception is thrown. 输入的日期无效时返回 std::nullopt。不会抛出异常。
◆ is_valid_gregorian()
Checks if the input gregorian date is valid and within the supported range. 检查输入的公历日期是否有效,且在支持的范围内。
- Parameters
-
- Returns
- true if valid, otherwise false. 如果有效,返回 true,否则返回 false。
◆ is_valid_lunar()
Checks if the input lunar date is valid and within the supported range. 检查输入的阴历日期是否有效,且在支持的范围内。
- Parameters
-
| lunar_date | The lunar date. 阴历日期。 |
- Returns
- true if valid, otherwise false. 如果有效,返回 true,否则返回 false。
- Attention
- The month is the positional index (see Converter's note): a leap month takes its own position. 月份是位置序号(见 Converter 的注):闰月独占一位。
◆ lunar_to_gregorian()
Converts lunar date to gregorian date. 将阴历日期转换为公历日期。
- Parameters
-
| lunar_date | The lunar date; its month is the positional index (see Converter's note). 阴历日期;其「月」是位置序号(见 Converter 的注)。 |
- Returns
- The optional gregorian date. 公历日期(optional)。
- Attention
- The input date should be in the supported range. 输入的日期需要在所支持的范围内。
-
std::nullopt is returned if the input date is invalid. No exception is thrown. 输入的日期无效时返回 std::nullopt。不会抛出异常。
The documentation for this struct was generated from the following file: