bazi.calendar.dates¶
历法日期、农历年表与节气时刻的数据类型。
CalendarType 区分历法,CalendarDate 承载日期,JieqiTime 与 GanzhiYearMonth 保存相应坐标。
- class bazi.calendar.dates.CalendarDate(year: int, month: int, day: int, date_type: CalendarType)[源代码]¶
带历法类型的不可变日期。构造时校验字段类型,不检查日期是否合法。
Note:
与非 CalendarDate 比较,dataclass 生成的
==/!=返回 False / True;排序抛 TypeError。不同 CalendarType 的日期不能排序,抛 TypeError。
- date_type: CalendarType¶
- day: int¶
- month: int¶
- year: int¶
- class bazi.calendar.dates.GanzhiYearMonth(year: int, month: int)[源代码]¶
干支年月坐标,以立春起年,月序为 1(寅)至 12(丑)。
Note:
坐标本身不限定历法表范围,也不指定出生、日期或时刻的归属粒度。
按年、月序排序;不与公历年月或 0-based 月偏移混用。
- classmethod from_dizhi(year: int, dizhi: Dizhi) GanzhiYearMonth[源代码]¶
从干支年与月支构造坐标,不接受公历月份。
- classmethod from_jie(jie: JieqiTime) GanzhiYearMonth[源代码]¶
真实节所开启的干支年月;中气不能开启干支月。
- month: int¶
- year: int¶