A Chinese Calendar Library in Pure Python
Chinese Calendar: http://en.wikipedia.org/wiki/Chinese_calendar
Install
pip install lunardate
Usage
>>> from lunardate import LunarDate
>>> LunarDate.from_solar_date(1976, 10, 1)
LunarDate(1976, 8, 8, 1)
>>> LunarDate(1976, 8, 8, 1).to_solar_date()
datetime.date(1976, 10, 1)
>>> LunarDate(1976, 8, 8, 1).year
1976
>>> LunarDate(1976, 8, 8, 1).month
8
>>> LunarDate(1976, 8, 8, 1).day
8
>>> LunarDate(1976, 8, 8, 1).is_leap_month
True
>>> today = LunarDate.today()
>>> type(today).__name__
'LunarDate'
>>> # support '+' and '-' between datetime.date and datetime.timedelta
>>> ld = LunarDate(1976,8,8)
>>> sd = datetime.date(2008,1,1)
>>> td = datetime.timedelta(days=10)
>>> ld-ld
datetime.timedelta(0)
>>> ld-sd
datetime.timedelta(-11444)
>>> ld-td
LunarDate(1976, 7, 27, 0)
>>> sd-ld
datetime.timedelta(11444)
>>> ld+td
LunarDate(1976, 8, 18, 0)
>>> td+ld
LunarDate(1976, 8, 18, 0)
>>> ld2 = LunarDate.today()
>>> ld < ld2
True
>>> ld <= ld2
True
>>> ld > ld2
False
>>> ld >= ld2
False
>>> ld == ld2
False
>>> ld != ld2
True
>>> ld == ld
True
>>> LunarDate.today() == LunarDate.today()
True
>>> LunarDate.leap_month_for_year(2023)
2
>>> LunarDate.leap_month_for_year(2022)
None
News
- 0.3.0: drop python 2, add typing hints, rename identifiers to follow PEP 8
- 0.2.2: add LunarDate.leapMonthForYear; fix bug in year 1899
- 0.2.1: fix bug in year 1956
- 0.2.0: extend year to 2099, thanks to @FuGangqiang
- 0.1.5: fix bug in
== - 0.1.4: support '+', '-' and compare, fix bug in year 2050
- 0.1.3: support python 3.0
Limits
this library can only deal with year from 1900 to 2099 (in chinese calendar).
See also
- lunar: http://packages.qa.debian.org/l/lunar.html, A converter written in C, this program is derived from it.
- python-lunar: http://code.google.com/p/liblunar/ Another library written in C, including a python binding.
Metadata
Release files for lunardate 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lunardate-0.3.0.tar.gz | 18.6 kB | Without provenance | Details for lunardate-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lunardate-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for lunardate-0.3.0-py3-none-any.whl |
Total release size: 37.4 kB
Release files / lunardate-0.3.0.tar.gz
| Download URL | lunardate-0.3.0.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae1daa9140bb1078b2c8e2a5b1623e6f25cf0443eca9ef2d6df27a4644f25fef
|
|
BLAKE2b-256 checksum How to use checksums |
4a706d4d14313b5d9eab05e37c761164dd572d95386bd6238354b04b989e0eae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / lunardate-0.3.0-py3-none-any.whl
| Download URL | lunardate-0.3.0-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68c1beaf7704c55c8a2c929d14be3ca98da55992d0ec3c0dd57eae2a5d4079fb
|
|
BLAKE2b-256 checksum How to use checksums |
1365b0f833b26f932c865efd25790960bb83481098d66ed8b4ceac8a91859433
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for lunardate 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.