Check if some day is holiday in china; Chinese lunar calendar.
Project description
中国节假日、农历、八字、A股交易日历查询工具
安装
pip install chncal dramkit --upgrade
项目地址: Gitee: ChnCal;Github: ChnCal;Pypi: chncal。
接口说明
参数中的date或time不传即默认为当前日期时间,date传参格式可为datetime格式或常见的文本格式或整数格,(如20250315,2025.03.15,2025-03-15,datetime.date(2025, 3, 15)都可以),返回格式默认与输入格式相同。
from chncal import * # 接口名称
中国节假日和工作日历查询(从2001年起)
is_workday(date=None): 判断date是否为工作日is_holiday(date=None): 判断date是否为假期get_holidays(start=None, end=None, include_weekends=True): 获取start和end之间的节假期列表,include_weekends设置是否包含正常周末get_workdays(start=None, end=None): 获取start和end之间的工作日列表find_workday(delta_days=0, date=None): 查找date之后的第delta_days个工作日get_next_nth_workday(date=None, n=1): 返回date后第n个工作日日期,n可为负数(返回结果在date之前),若n为0,直接返回dateget_recent_workday(date=None, dirt='post'): 若date为工作日,则直接返回,否则返回下一个(dirt为post时)或上一个(dirt为pre时)工作日
星座查询
get_xingzuo(date=None): 查询date的星座
农历查询
get_solar_terms(start=None, end=None): 查询start和end日期之间的24节气列表sol2lun(date=None): 公历日期转农历日期sol2gz(date=None): 公历日期转干支纪日法lun2sol(date, run=False): 农历日期转普通日期,date格式必须形如'2023.02.30',run为True表示闰月日期
八字查询
get_bazi(time=None): 根据公历时间生成八字get_bazi_lunar(time, run=False): 根据农历时间生成八字,time格式必须形如'2023.02.30 19:30:20',时分秒可以不写,run为True表示闰月日期get_wuxing(time=None): 根据公历时间获取五行信息get_wuxing_lunar(time, run=False): 根据农历时间获取五行信息,time格式必须形如'2023.02.30 19:30:20',run为True表示闰月日期get_marry_match(time=None): 根据公历时间获取属相合婚信息get_marry_match_lunar(time, run=False): 根据农历时间获取属相合婚信息,time格式必须形如'2023.02.30 19:30:20',run为True表示闰月日期get_chengming(time=None): 称命,传入公历时间get_chengming_lunar(time, run=False): 称命,传入农历时间get_age_by_shuxiang(shuxiang, year: int = None): 根据属性获取可能年龄
A股交易日历查询
is_tradeday(date=None: 判断是否为交易日get_recent_tradeday(date=None, dirt='post'): 查询最近的交易日,若date为交易日,则直接返回date,否则返回下一个(dirt='post')或上一个(dirt='pre')交易日get_next_nth_tradeday(date=None, n=1):- 给定日期date,返回其后第n个交易日日期,n可为负数(返回结果在date之前),若n为0,直接返回date
get_trade_dates(start_date, end_date=None): 取指定起止日期内的交易日期(周内的工作日)
参考
chinese_calendar: github
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chncal-3.1.2025.tar.gz
(1.4 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chncal-3.1.2025.tar.gz.
File metadata
- Download URL: chncal-3.1.2025.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd003235432a327fbc0d20d99bcfa540f70f94095697dfdaffa8c4ca0c5f0503
|
|
| MD5 |
2fabd62d745042ab8f4d99f0bb51ee5c
|
|
| BLAKE2b-256 |
a1e9c6e3db3a1fa74280a776cdb4a939cc30c2df41a4a9a4331e76eafa2a95e8
|
File details
Details for the file chncal-3.1.2025-py3-none-any.whl.
File metadata
- Download URL: chncal-3.1.2025-py3-none-any.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f901e829ead67acb6a411b89fddf8e9a980aa17ebb69ad569a66212a025dff38
|
|
| MD5 |
36ec2f512a1bfb1bc9ec4cd430287e0b
|
|
| BLAKE2b-256 |
8e96d8f6173404b4f65c3999778289e472eb2a6ae961f6338ad27d69e213e35f
|