Skip to main content

A Python package about Chinese Lunisolar Calendar.

Project description

Chinese Calendar Date

力求简单、稳定、高效的农历日期 Python 库。

功能一览

  • 农历日期的判等和比较
  • 农历日期的加减(与datetime.timedelta
  • 农历日期的数字化和汉字化
  • 公农历的互相转换
    • 范围有限的快速转换(FastCCD
    • 范围无限的计算转换(EphemCCD
  • 支持 Pickle 协议
  • 中文文档注释

兼容性

目前仅支持使用 Python 3.11 及以上版本运行。
如果希望支持旧版本,可以提出 Issue 并注明希望支持的最低版本,或点赞表态,也欢迎参与翻译。

快速上手

安装

pip install CCD

使用

from datetime import date, timedelta
from ccd import FastCCD

gcd = date.today()
print(str(gcd))  # '2020-06-20'

ccd = FastCCD.from_date(gcd)
print(str(ccd))  # '农历2020年闰四月廿九'
print(repr(ccd))  # 'ccd.base.FastCCD(2020, 4, 29, True)'

ccd += timedelta(days=1)
print(str(ccd))  # '农历2020年五月初一'
print(repr(ccd))  # 'ccd.base.FastCCD(2020, 5, 1, False)'

gcd = ccd.to_date()
print(str(gcd))  # '2020-06-21'

说明

农历日期类有以下几个:

  • ccd.EphemCCD,无限范围。需要安装 PyEphem 库后才可用。
  • ccd.FastCCD,有限范围。无论何时都可用。
  • ccd.ChineseCalendarDate,无论何时都可用。
    • 默认情况下等同于 FastCCD
    • 安装 PyEphem 库后等同于 EphemCCD

问题反馈

码云:https://gitee.com/aixcyi/CCD/issues
GitHub:https://github.com/aixcyi/CCD/issues

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

CCD-0.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file CCD-0.2-py3-none-any.whl.

File metadata

  • Download URL: CCD-0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for CCD-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d64062daae73443ccdfec9d8a6c2aebdf2b900c7b785433e2fa1c8ace9e1319c
MD5 8ca577ea368e718ea88e88d97dddbe7d
BLAKE2b-256 1d4faa5ac838bf4b2cda36824c67218fda19a686a18d6c965ef8032e8d4c7bcb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page