skillfed

suntimes

For a given place (longitude, latitude and altitude) and a given day, returns the time of sunrise and the time of sunset (in UTC and in local time). Create and save a json or csv file with the timetables for a whole year. Calculations valid beyond the polar circles; returns Polar Day or Polar Night if needed.

suntimes v1.1.2 227.9K downloads/30d#9,163 on PyPI7
Permissive license MIT License Copyright (c) [2022] [Paul MATHIS] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) Abandoned released

What it is and what it does

SunTimes is a Python library that computes sunrise and sunset times for a given geographic location and date. You provide longitude, latitude, and optional altitude, then call methods to retrieve times in UTC, local computer time, or any specified timezone. The library handles edge cases like polar day and polar night, returning special indicators when the sun does not rise or set. It also offers convenience methods to extract just the hour and minute, calculate day length, and generate annual timetables as JSON or CSV files.

The package relies on astronomical calculations based on the sunrise equation (from Wikipedia) and uses pytz, tzlocal, and jdcal for timezone and calendar math. Calculations are accurate to within one to several minutes. The library is straightforward to use for applications like solar energy planning, outdoor activity scheduling, or astronomy tools, but it is no longer maintained—the last commit was in February 2023 and no updates have been released since July 2022.

Use it for:

  • Schedule outdoor activities or events by retrieving sunrise/sunset times for a specific location and date.
  • Generate annual solar timetables for a location in JSON or CSV format for reporting or spreadsheet analysis.
  • Calculate day length (duration of daylight) for a location to inform energy consumption or agricultural planning.
  • Detect and handle polar day/polar night conditions in high-latitude applications.
  • Build solar energy or astronomy tools that need accurate sun position times across multiple timezones.

Worth the install?

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

Calculates sunrise and sunset times for any geographic location (longitude, latitude, altitude) on a given date, handling polar regions where day/night calculations differ.

Yes, if you need straightforward sunrise/sunset calculations and can accept that the package is no longer maintained. The code is stable, has no known vulnerabilities, and the three dependencies are well-established. Install it for one-off scripts or prototypes; for production systems where you may need bug fixes or Python version updates, consider whether an actively maintained alternative is available or whether you can fork and maintain it yourself.

Install

suntimes on PyPI

pip

pip install suntimes

uv

uv add suntimes

poetry

poetry add suntimes

Installing suntimes

Before you install

Low install friction with three stable runtime dependencies (pytz, tzlocal, jdcal). However, the package is abandoned—last commit was 2023-02-08 and no updates since July 2022. No active maintenance means bug fixes or compatibility updates are unlikely.

License in practice

MIT License permits unrestricted use, modification, and distribution with minimal restrictions. You may use this package freely in commercial and private projects, provided you retain the copyright notice and license text.

Quickstart

from datetime import datetime
from suntimes import SunTimes

day = datetime(2021, 1, 6)
sun = SunTimes(2.349902, 48.852968, 35)  # longitude, latitude, altitude
rise = sun.riseutc(day)  # datetime(2021, 1, 6, 7, 43)
set_time = sun.setutc(day)  # datetime(2021, 1, 6, 16, 12)

Verify before relying

  • Accuracy degradation near polar regions—fact sheet notes 'the closer you get to the poles, the lower the accuracy' but does not quantify the error margin.
  • Whether calculations remain valid for dates far in the past or future, or only near the present era.
  • Compatibility with Python versions beyond 3.6 in practice, given the package is abandoned.

Package facts

License MIT License Copyright (c) [2022] [Paul MATHIS] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.6)
Install friction low — pure-Python wheel
Runtime dependencies 3 — pytz, tzlocal, jdcal
Maintenance abandoned — 1,505 days since the last release
Last repo commit
First released
Downloads 227,889/month — #9,163 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: suntimes-1.1.2-py3-none-any.whl

Keywords: sun, sunset, sunrise, python

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

sunrise sunset time calculationsolar time by locationdawn dusk times coordinatespolar day polar night detectionsun position astronomy pythondaylight duration calculatorsolar ephemeris library
astronomysolar-timegeolocation

More Scientific/Engineering packages