
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Python版阳历转农历
pip install pyunit-calendar
from pyunit_calendar import LunarDate,LunarSolarDateConverter,SolarDate
if __name__ == "__main__":
"""测试简单快速的农历和阳历互转"""
converter = LunarSolarDateConverter()
lunar = converter.solar_to_lunar(SolarDate(2019, 12, 6))
print(lunar)
# {"isleap": False, "lunarDay": 11, "lunarMonth": 11, "lunarYear": 2019}
solar = converter.lunar_to_solar(LunarDate(2019, 11, 10))
print(solar)
# {"solarDay": 5, "solarMonth": 12, "solarYear": 2019}
from pyunit_calendar import SC
if __name__ == "__main__":
lun = SC(year=2018, month=1, day=2) #阳历转农历
print(lun.y) # 农历的年,中文字符 二零一九
print(lun.year) # 农历的年,阿拉伯数字 2019
print(lun.m) # 农历的月份 中文字符 七
print(lun.month) # 农历的月份 阿拉伯字符 7
print(lun.d) # 农历的日期 中文字符 十四
print(lun.day) # 阳历的日期 阿拉伯数字 15 ,注意。和农历不一样
print(lun.w) # 星期几 中文字符
print(lun.week) # 星期几、英文字符
print(lun.h) # 节日
print(lun) # 二零一九年 七月 十四 星期四 无
from pyunit_calendar import CTC
if __name__ == "__main__":
c = CTC(ctc_year=2017, ctc_mon=-6, ctc_day=8) # 农历的日期2017年闰6月初八
print(c.find_sc()) # 阳历:2017年7月30日
print(c.get_year()) # 2017
print(c.get_month()) # 7
print(c.get_day()) # 30
from pyunit_calendar import BatchCalendar
if __name__ == "__main__":
bc=BatchCalendar() #下载数据
print("-----------------------------")
# 农历
print(bc.ctc_to_sc("1984年闰十月初三")) # 农历转阳历 1984年11月25日
print(bc.ctc_to_td("1984年闰十月初三")) # 农历转天干地支 甲子年乙亥月癸亥日
print("-----------------------------")
# 阳历
print(bc.sc_to_ctc("1984年11月25日")) # 阳历转农历 1984年闰十月初三
print(bc.sc_to_td("1984年11月25日")) # 阳历转天干地支 甲子年乙亥月癸亥日
print("-----------------------------")
# 天干地支
print(bc.td_to_ctc("甲子年乙亥月癸亥日")) # 天干地支转农历:["1984年闰十月初三", "2044年九月廿一"]
print(bc.td_to_sc("甲子年乙亥月癸亥日")) # 天干地支转阳历:["1984年11月25日", "2044年11月10日"]
docker pull pyunit-calendar
docker run -P -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime -d pyunit-calendar
参数名 | 类型 | 是否可以为空 | 说明 |
---|---|---|---|
year | int | YES | 输入阿拉伯数字的年 |
month | int | YES | 输入阿拉伯数字的月(如果是闰月前面添加负号:如-4表示闰4月) |
day | int | YES | 输入阿拉伯数字的日 |
Python3 Requests测试
import requests
url = "http://127.0.0.1:32768/pyunit/calendar/LunarCalendar"
data = {
"year": 2020,
"month": -4,
"day": 11
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=data, headers=headers).json()
print(response)
返回结果
{
"code": 200,
"result": {
"date": "2020年6月2日",
"day": "2",
"month": "6",
"year": "2020"
}
}
参数名 | 类型 | 是否可以为空 | 说明 |
---|---|---|---|
year | int | YES | 输入阿拉伯数字的年 |
month | int | YES | 输入阿拉伯数字的月 |
day | int | YES | 输入阿拉伯数字的日 |
Python3 Requests测试
import requests
url = "http://127.0.0.1:32768/pyunit/calendar/SolarCalendar"
data = {
"year": 2020,
"month": 6,
"day": 2
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=data, headers=headers).json()
print(response)
返回结果
{
"code": 200,
"result": {
"date": "二零二零年 闰四月 十一 星期二 节日:无",
"day": "十一",
"holiday": "无",
"is_leap": "是",
"month": "闰四",
"week": "星期二",
"year": "二零二零"
}
}
参数名 | 类型 | 是否可以为空 | 说明 |
---|---|---|---|
date | string | YES | 输入当前的日期:可以输入三种格式,具体看请求示例 |
Python3 Requests测试
import requests
url = "http://127.0.0.1:32768/pyunit/calendar/BatchCalendar"
data = {
"date": '2020年四月十一', # 农历格式:阿拉伯数字+年+中文数字+月+中文数字
# "date": "2020年05月03日", # 农历格式:阿拉伯数字+年+阿拉伯数字+月+阿拉伯数字+日
# "date": "庚子年庚辰月丙午日", # 农历格式:天干地支+年+天干地支+月+天干地支+日
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=data, headers=headers).json()
print(response)
返回结果
{
"code": 200,
"result": {
"HSTTB": "庚子年庚辰月丙午日",
"LunarCalendar": "2020年四月十一",
"SolarCalendar": "2020年05月03日"
}
}
FAQs
We found that pyunit-calendar demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.