Simple sunset and sunrise time calculation Python library. Current version 1.3.2. Released irregularly.
pip install suntimeVerified import paths — ran on the pinned version, not inferred.
Initialize Sun with latitude and longitude, then call get_sunrise_time/get_sunset_time with a date.
Use get_sunrise_time and get_sunset_time which return UTC datetime objects. Convert to local timezone with pytz or zoneinfo.
Ensure correct sign: e.g., London is +51.5, -0.13.
Understand that reported seconds are approximate; do not rely on sub-minute accuracy.
Pass a datetime.date object: e.g., datetime.now().date().
Upgrade to latest version: pip install --upgrade suntime. Or use get_local_sunrise_time if staying on older version.
Check coordinate values. For example, lat=51.5, lon=-0.13.
Use .date() on datetime: e.g., sun.get_sunrise_time(datetime.now().date()).
No dependency data recorded yet.