Skip to main content

A Chinese Calendar Library in Pure Python

Project description

A Chinese Calendar Library in Pure Python

Python package PyPI - Version PyPI - Downloads

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

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.3.0.tar.gz (18.6 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.3.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lunardate-0.3.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for lunardate-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ae1daa9140bb1078b2c8e2a5b1623e6f25cf0443eca9ef2d6df27a4644f25fef
MD5 954a0f41ab2abd769f909782f5c65bd3
BLAKE2b-256 4a706d4d14313b5d9eab05e37c761164dd572d95386bd6238354b04b989e0eae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lunardate-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for lunardate-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68c1beaf7704c55c8a2c929d14be3ca98da55992d0ec3c0dd57eae2a5d4079fb
MD5 0068a7aa2ec808d47c4674e5105fc07c
BLAKE2b-256 1365b0f833b26f932c865efd25790960bb83481098d66ed8b4ceac8a91859433

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