ZhDate 中国农历日期处理对象
不用网络接口直接本地计算中国农历,支持农历阳历互转
感谢
EillesWan
更新
安装方法
通过 pip 直接安装
pip install zhdate
或从git拉取
git clone https://github.com/CutePandaSh/zhdate.git
cd zhdate
python setup.py install
更新
pip install zhdate --upgrade
使用方法
见如下代码案例:
from zhdate import ZhDate
date1 = ZhDate(2010, 1, 1)
print(date1)
dt_date1 = date1.to_datetime()
dt_date2 = datetime(2010, 2, 6)
date2 = ZhDate.from_datetime(dt_date2)
date3 = ZhDate(2020, 4, 30, leap_month=True)
print(date3.to_datetime())
if ZhDate(2019, 1, 1) == ZhDate.from_datetime(datetime(2019, 2, 5)):
pass
new_zhdate = ZhDate(2019, 1, 1) - 30
new_zhdate2 = ZhDate(2019, 1, 1) - ZhDate(2018, 1, 1)
new_zhdate3 = ZhDate(2019, 1, 1) - datetime(2019, 1, 1)
new_zhdate4 = ZhDate(2019, 1, 1) + 30
new_zhdate5 = ZhDate(2019, 1, 1)
print(new_zhdate5.chinese())
ZhDate.today()