{"id":4093,"library":"lunardate","title":"lunardate: Chinese Calendar Library","description":"lunardate is a Chinese Calendar Library implemented purely in Python. It provides functionalities to convert between solar and lunar dates, handle leap months, and perform date arithmetic. The library is currently at version 0.2.2 and sees infrequent but consistent updates, with recent fixes and year range extensions.","status":"active","version":"0.2.2","language":"en","source_language":"en","source_url":"https://github.com/lidaobing/python-lunardate","tags":["calendar","lunar","chinese","date-time"],"install":[{"cmd":"pip install lunardate","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"LunarDate","correct":"from lunardate import LunarDate"}],"quickstart":{"code":"import datetime\nfrom lunardate import LunarDate\n\n# Convert a solar date to a lunar date\nlunar_date = LunarDate.fromSolarDate(1976, 10, 1)\nprint(f\"Lunar Date for 1976-10-01: {lunar_date}\")\n# Expected: LunarDate(1976, 8, 8, 1) (year, month, day, isLeapMonth)\n\n# Convert a lunar date back to a solar date\nsolar_date = LunarDate(1976, 8, 8, 1).toSolarDate()\nprint(f\"Solar Date for LunarDate(1976, 8, 8, 1): {solar_date}\")\n# Expected: 1976-10-01\n\n# Get today's lunar date\ntoday_lunar = LunarDate.today()\nprint(f\"Today's Lunar Date: {today_lunar}\")\n\n# Check for leap month in a year\nleap_month_2023 = LunarDate.leapMonthForYear(2023)\nprint(f\"Leap month for 2023: {leap_month_2023}\") # Expected: 2\n\nleap_month_2022 = LunarDate.leapMonthForYear(2022)\nprint(f\"Leap month for 2022: {leap_month_2022}\") # Expected: None","lang":"python","description":"Demonstrates converting between solar and lunar dates, getting the current lunar date, and checking for leap months."},"warnings":[{"fix":"Ensure that all solar and lunar dates used with the library fall within the 1900-2099 range. Consider alternative libraries for dates outside this range.","message":"The library is limited to processing years between 1900 and 2099 (inclusive of 1900, exclusive of 2099 for internal calculations). Input or output dates outside this range will raise a ValueError.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to version 0.2.0 or newer to utilize the extended year range (up to 2099).","message":"Earlier versions (e.g., 0.1.x) had a more restricted year range, only supporting up to 2050. Version 0.2.0 extended this range to 2099.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Always use the latest stable version (0.2.2 or newer) to benefit from bug fixes and ensure accuracy for specific dates and operations.","message":"Older versions contained bugs related to specific years (e.g., 1899, 1956, 2050) or date comparison logic (`==` operator). These have been addressed in recent patches.","severity":"breaking","affected_versions":"<0.2.2"},{"fix":"Review the GPLv3 license terms to confirm compatibility with your project's legal requirements.","message":"The library is licensed under GPLv3. Ensure this license is compatible with your project's licensing requirements before integration.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}