ZhDate¶
- class zvt.misc.zhdate.ZhDate(lunar_year, lunar_month, lunar_day, leap_month=False)¶
Bases:
object- __init__(lunar_year, lunar_month, lunar_day, leap_month=False)¶
初始化函数
- Arguments:
lunar_year {int} – 农历年 lunar_month {int} – 农历月份 lunar_day {int} – 农历日
- Keyword Arguments:
leap_month {bool} – 是否是在农历闰月中 (default: {False})
- to_datetime()¶
农历日期转换称公历日期
- Returns:
datetime – 当前农历对应的公历日期
- static from_datetime(dt)¶
静态方法,从公历日期生成农历日期
- Arguments:
dt {datetime} – 公历的日期
- Returns:
ZhDate – 生成的农历日期对象
- static validate(year, month, day, leap)¶
农历日期校验
- Arguments:
year {int} – 农历年份 month {int} – 农历月份 day {int} – 农历日期 leap {bool} – 农历是否为闰月日期
- Returns:
bool – 校验是否通过
- static decode(year_code)¶
解析年度农历代码函数
- Arguments:
year_code {int} – 从年度代码数组中获取的代码整数
- Returns:
list[int, ] – 当前年度代码解析以后形成的每月天数数组,已将闰月嵌入对应位置,即有闰月的年份返回的列表长度为13,否则为12
- static month_days(year)¶
根据年份返回当前农历月份天数list
- Arguments:
year {int} – 1900到2100的之间的整数
- Returns:
[int] – 农历年份所对应的农历月份天数列表