Registry / data / suntime

suntime

JSON →
library1.3.2pypypi✓ verified 85d ago

Simple sunset and sunrise time calculation Python library. Current version 1.3.2. Released irregularly.

pip install suntime
INSTALL
IMPORT
SIG · SUNTIME
S
suntime
datapythonv1.3.2
Install
1.8s avg
Import
10ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.2 · 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.002s · 18.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.002s · 19MB
17MB installed
● package 17MB
Code
Verified usage

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

Sun
from suntime import Sun

Initialize Sun with latitude and longitude, then call get_sunrise_time/get_sunset_time with a date.

from suntime import Sun from datetime import datetime, timedelta # Example coordinates: London lat = 51.5 lon = -0.13 sun = Sun(lat, lon) # Get sunrise and sunset for today today = datetime.now().date() sunrise = sun.get_sunrise_time(today) sunset = sun.get_sunset_time(today) print(f"Sunrise: {sunrise}, Sunset: {sunset}") # Deprecated (remove in future): get_local_sunrise_time, get_local_sunset_time # sunrise_local = sun.get_local_sunrise_time(today) # sunset_local = sun.get_local_sunset_time(today)
Debug
Known issues
deprecatedget_local_sunrise_time and get_local_sunset_time are deprecated since v1.3.0.
fix
Use get_sunrise_time and get_sunset_time which return UTC datetime objects. Convert to local timezone with pytz or zoneinfo.
affects: >=1.3.0
gotchaCoordinates are in decimal degrees. Negative longitude for west, negative latitude for south.
fix
Ensure correct sign: e.g., London is +51.5, -0.13.
affects: all
gotchaResults are approximate (seconds calculation depends on orography).
fix
Understand that reported seconds are approximate; do not rely on sub-minute accuracy.
affects: >=1.3.0
gotchaget_sunrise_time and get_sunset_time require a date object (not datetime).
fix
Pass a datetime.date object: e.g., datetime.now().date().
affects: all
Errors
Common errors & fixes
AttributeError: 'Sun' object has no attribute 'get_sunrise_time'
Using an older version of suntime (<1.3.0) where only get_local_sunrise_time existed.
fix
Upgrade to latest version: pip install --upgrade suntime. Or use get_local_sunrise_time if staying on older version.
ValueError: Invalid latitude/longitude
Latitude or longitude out of range. Latitude must be -90 to 90, longitude -180 to 180.
fix
Check coordinate values. For example, lat=51.5, lon=-0.13.
TypeError: unsupported type for timedelta seconds component: datetime.date
Passing a datetime object instead of date object to get_sunrise_time/get_sunset_time.
fix
Use .date() on datetime: e.g., sun.get_sunrise_time(datetime.now().date()).
Upgrade
Version history
1.3.2latest on PyPI · released Mar 10, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
suntime — pip install suntime · libregistry