{"id":24867,"library":"zhdate","title":"Zhdate","description":"A Python library to convert Chinese Lunar Calendar (农历) to datetime and vice versa. Supports lunar dates from 1900 to 2100. Current version: 1.0. Release cadence is irregular; last release was 2024.","status":"active","version":"1.0","language":"python","source_language":"en","source_url":"https://github.com/CutePandaSh/zhdate","tags":["chinese-lunar-calendar","calendar","date-conversion","lunar"],"install":[{"cmd":"pip install zhdate","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"","symbol":"ZhDate","correct":"from zhdate import ZhDate"}],"quickstart":{"code":"from zhdate import ZhDate\n\n# Convert Chinese lunar date to Gregorian date\nlunar_date = ZhDate(2024, 1, 1)  # 2024-01-01 in lunar calendar\ngregorian_date = lunar_date.to_datetime()\nprint(gregorian_date)  # Output: 2024-02-10 00:00:00\n\n# Convert Gregorian date to Chinese lunar date\ngregorian_dt = datetime.date(2024, 2, 10)\nlunar_date = ZhDate.from_datetime(gregorian_dt)\nprint(lunar_date)  # Output: ZhDate(2024, 1, 1)\n\n# Leap month example\nlunar_date_leap = ZhDate(2023, 2, 1, leap_month=True)  # Leap second month\nprint(lunar_date_leap.to_datetime())","lang":"python","description":"Basic usage: creating ZhDate objects and converting between lunar and Gregorian dates."},"warnings":[{"fix":"Always use month=1 for January, day=1 for first day.","message":"ZhDate uses 1-indexed months and days (January = 1), unlike some lunar libraries that use 0-indexed.","severity":"gotcha","affected_versions":"all"},{"fix":"When creating a leap month, pass leap_month=True (e.g., ZhDate(2023, 2, 1, leap_month=True)).","message":"Leap months must be explicitly specified with leap_month=True. The library does not auto-detect leap months.","severity":"gotcha","affected_versions":"all"},{"fix":"Use ZhDate.from_datetime(date_obj) as documented; watch for alternative static methods.","message":"The from_datetime method may be renamed or behavior changed in future versions. Check changelog.","severity":"deprecated","affected_versions":">=1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure month is between 1 and 12. For example, use month=1 for January.","cause":"ZhDate expects month 1-12, not 0-11.","error":"ValueError: month must be in 1..12"},{"fix":"Use `from zhdate import ZhDate` or `import zhdate; zhdate.ZhDate`.","cause":"Typo or incorrect import (e.g., `import zhdate` then `zhdate.ZhDate` is correct, but some try `zhdate.zhdate`).","error":"AttributeError: module 'zhdate' has no attribute 'ZhDate'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}