skillfed

suntime

Simple sunset and sunrise time calculation python library

suntime v1.3.2 212.8K downloads/30d#9,451 on PyPI120
Copyleft license LGPLv3 DORMANT released

What it is and what it does

SunTime is a lightweight Python library that computes sunrise and sunset times for any geographic location and date. It takes latitude and longitude as input and returns datetime objects representing when the sun rises and sets, either in UTC or in a specified local timezone. The library handles the mathematical complexity of solar position calculations internally, so you don't need to implement the astronomy yourself.

The main use case is applications that need to know daylight hours—weather apps, scheduling systems, outdoor activity planners, or any tool that must adapt behavior based on solar events. It includes error handling for edge cases like polar regions where the sun may not rise or set on certain dates, raising SunTimeException when these conditions occur. The library depends only on python-dateutil for timezone handling.

Use it for:

  • Determine daylight hours for a given location and date in a weather or outdoor activity app
  • Schedule tasks or alerts to trigger at sunrise or sunset in a user's local timezone
  • Calculate solar noon or twilight times for photography, astronomy, or solar energy applications
  • Validate whether a location experiences midnight sun or polar night on a specific date
  • Build a calendar or scheduling UI that highlights daylight and darkness periods

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Calculates sunrise and sunset times for any geographic location and date, handling edge cases like polar regions where the sun may not rise or set.

Yes, if you need straightforward sunrise/sunset calculations. The library is simple, has low install friction, no known vulnerabilities, and a stable API. However, maintenance is dormant—no updates since March 2024—so if you need active support or frequent bug fixes, consider whether this is acceptable for your use case. The LGPLv3 license is permissive for most projects but requires attention if you're building proprietary software.

Install

suntime on PyPI

pip

pip install suntime

uv

uv add suntime

poetry

poetry add suntime

Installing suntime

Before you install

Low friction: pure Python wheel with a single runtime dependency on python-dateutil. Last release was in March 2024; the repository is dormant but not archived, with no recent activity to suggest active maintenance.

License in practice

Licensed under LGPLv3 (copyleft). You may use and modify the library freely, but any derivative work must also be distributed under LGPLv3 or a compatible license.

Quickstart

pip install suntime

from suntime import Sun
import datetime

sun = Sun(51.21, 21.01)  # Warsaw coordinates
today_sr = sun.get_sunrise_time()
today_ss = sun.get_sunset_time()
print(f'Sunrise: {today_sr}, Sunset: {today_ss}')

Verify before relying

  • Accuracy of calculations and whether they match standard astronomical references
  • Whether polar-region edge cases (midnight sun, polar night) are handled correctly in all scenarios
  • Current maintenance status and likelihood of bug fixes or updates

Package facts

License LGPLv3 (copyleft)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — python-dateutil
Maintenance dormant — 887 days since the last release
Last repo commit
First released
Downloads 212,778/month — #9,451 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: suntime-1.3.2-py3-none-any.whl

Tags

sunrise sunset time calculationsolar times by latitude longitudesun position astronomydaylight hours calculatorsolar event timesgeographic sunrise sunset
astronomysolar-calculationsgeolocation

More Utilities packages