A Chinese Calendar Library in Pure Python
Project description
Chinese Calendar: http://en.wikipedia.org/wiki/Chinese_calendar
Usage
>>> LunarDate.fromSolarDate(1976, 10, 1) LunarDate(1976, 8, 8, 1) >>> LunarDate(1976, 8, 8, 1).toSolarDate() 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).isLeapMonth 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).days -11444 >>> ld-td LunarDate(1976, 7, 27, 0) >>> (sd-ld).days 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 >>> before_leap_month = LunarDate.fromSolarDate(2088, 5, 17) >>> before_leap_month.year 2088 >>> before_leap_month.month 4 >>> before_leap_month.day 27 >>> before_leap_month.isLeapMonth False >>> leap_month = LunarDate.fromSolarDate(2088, 6, 17) >>> leap_month.year 2088 >>> leap_month.month 4 >>> leap_month.day 28 >>> leap_month.isLeapMonth True >>> after_leap_month = LunarDate.fromSolarDate(2088, 7, 17) >>> after_leap_month.year 2088 >>> after_leap_month.month 5 >>> after_leap_month.day 29 >>> after_leap_month.isLeapMonth False>>> LunarDate.leapMonthForYear(2023) 2 >>> LunarDate.leapMonthForYear(2022) None
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lunardate-0.2.2.tar.gz
(17.7 kB
view details)
Built Distribution
lunardate-0.2.2-py3-none-any.whl
(18.1 kB
view details)
File details
Details for the file lunardate-0.2.2.tar.gz
.
File metadata
- Download URL: lunardate-0.2.2.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ff8c01721bef7710f0712a302b1cb7d0b8b3ffc72a63a9a056cd01e58e5485a |
|
MD5 | a09dcd87cb3298d50b4f84d0b824cb1f |
|
BLAKE2b-256 | 857162fadf243502618cf2a7af5b81936a99684147c655729934f014758c3b39 |
File details
Details for the file lunardate-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: lunardate-0.2.2-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf1916337e50470a82df12d885ff47a456e89c91a3ad4e5fdf1575e063a7ed55 |
|
MD5 | 0f6436373099606e9b815d044c98a8e8 |
|
BLAKE2b-256 | a307232401bb1c6bc699c5e641ad375e2582cdde90b19b18e6618ec51796b737 |