Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lunardate

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lunardate

A Chinese Calendar Library in Pure Python

  • 0.2.1
  • PyPI
  • Socket score

Maintainers
1

A Chinese Calendar Library in Pure Python

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc