Registry / database / lunardate

lunardate

JSON →
library0.3.0pypypi✓ verified 23d ago

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.

pip install lunardate
INSTALL
IMPORT
SIG · LUNARDATE
L
lunardate
databasepythonv0.3.0
Install
1.5s avg
Import
13ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.014s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.012s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LunarDate
from lunardate import LunarDate

Demonstrates converting between solar and lunar dates, getting the current lunar date, and checking for leap months.

import datetime from lunardate import LunarDate # Convert a solar date to a lunar date lunar_date = LunarDate.fromSolarDate(1976, 10, 1) print(f"Lunar Date for 1976-10-01: {lunar_date}") # Expected: LunarDate(1976, 8, 8, 1) (year, month, day, isLeapMonth) # Convert a lunar date back to a solar date solar_date = LunarDate(1976, 8, 8, 1).toSolarDate() print(f"Solar Date for LunarDate(1976, 8, 8, 1): {solar_date}") # Expected: 1976-10-01 # Get today's lunar date today_lunar = LunarDate.today() print(f"Today's Lunar Date: {today_lunar}") # Check for leap month in a year leap_month_2023 = LunarDate.leapMonthForYear(2023) print(f"Leap month for 2023: {leap_month_2023}") # Expected: 2 leap_month_2022 = LunarDate.leapMonthForYear(2022) print(f"Leap month for 2022: {leap_month_2022}") # Expected: None
Debug
Known issues
gotchaThe 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.
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.
affects: All versions
breakingEarlier 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.
fix
Upgrade to version 0.2.0 or newer to utilize the extended year range (up to 2099).
affects: <0.2.0
breakingOlder versions contained bugs related to specific years (e.g., 1899, 1956, 2050) or date comparison logic (`==` operator). These have been addressed in recent patches.
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.
affects: <0.2.2
gotchaThe library is licensed under GPLv3. Ensure this license is compatible with your project's licensing requirements before integration.
fix
Review the GPLv3 license terms to confirm compatibility with your project's legal requirements.
affects: All versions
Errors
Common errors & fixes
ValueError: year must be between 1900 and 2099
The lunardate library only supports years between 1900 and 2099; inputting a year outside this range raises a ValueError.
fix
Ensure that all dates used with the lunardate library fall within the 1900-2099 range. For dates outside this range, consider using an alternative library.
ImportError: cannot import name 'LunarDate' from 'lunardate'
Attempting to import 'LunarDate' directly from the 'lunardate' module without proper installation or due to an incorrect import statement.
fix
Ensure the lunardate library is installed using 'pip install lunardate', and import it correctly: 'from lunardate import LunarDate'.
TypeError: unsupported operand type(s) for +: 'LunarDate' and 'datetime.date'
The lunardate library does not support direct arithmetic operations between 'LunarDate' and 'datetime.date' objects.
fix
Convert 'LunarDate' to 'datetime.date' using 'toSolarDate()' before performing arithmetic operations.
LunarDateError: Date out of range: YYYY-MM-DD (solar/lunar)
The lunardate library supports a specific range of dates (e.g., 1900-2100); inputting dates outside this range will raise an error.
fix
Ensure the solar or lunar date you are trying to convert or create falls within the library's supported range (1900-2100 by default).
ModuleNotFoundError: No module named 'lunardate'
The 'lunardate' package is not installed in your current Python environment or the environment is not correctly activated.
fix
Install the library using pip: `pip install lunardate`
Upgrade
Version history
0.3.0latest on PyPI · released Jul 7, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
87 hits · last 30 days
node
86
Resources
lunardate — pip install lunardate · libregistry