Skip to main content

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

Limits

this library can only deal with year from 1900 to 2099 (in chinese calendar).

See also

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

lunardate-0.2.1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lunardate-0.2.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file lunardate-0.2.1.tar.gz.

File metadata

  • Download URL: lunardate-0.2.1.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for lunardate-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f092417850973eb58e1eaee0c13dd50ab9d1cae35ed348ff5840e8e1e322fe6a
MD5 f1f5b4278aaccd69d6702aa30fa6ffe1
BLAKE2b-256 9c5086b2dc1ec6e97d952e17b3369473c62ec8fe1b90e1464898f681d7b15961

See more details on using hashes here.

File details

Details for the file lunardate-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: lunardate-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for lunardate-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4b4ba8855058266c436154946be8778cdfc3c45ac2956098454b66df2eaa644
MD5 831f9469e1697768f43e348ea80ab09b
BLAKE2b-256 4bcbff3dabf10e658970e67050bc76d3ddf180c44b9d9b4280ba8995f8e9db2e

See more details on using hashes here.

Supported by

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