Sunrise Sunset
The MIT License (MIT)
Overview
Python API to determine sunrise and sunset. It accepts five zenths: official civil, nautical, amateur, and astronomical.
Basic Usage
import datetime
from sunrisesunset import SunriseSunset
dt = datetime.datetime.now()
rs = SunriseSunset(dt, lat=35.9513, lon=83.9142, zenith='official')
rise_time, set_time = rs.sun_rise_set
print(f" Sunrise: {rise_time}")
print(f" Sunset: {set_time}")
print(f" Is night: {rs.is_night()}\n")
Running the Test
The pip installed package will not be enough to run the test. You will also need to pip install geopy and timezonefinder.
There is a more complete example in the test at the end of the `sunrisesunset.py` file.
You will be asked for an address, just a city name is okay. Then you will be asked for the time. It takes an ISO formatted time at minimum the year, month, and day needs to be entered.
python sunrisesunset/sunrisesunset.py
Enter an address: Chicago
Chicago, Cook County, Illinois, United States
Enter date in ISO format (yyyy-mm-dd hh:mm:ss): 2023-12-16 12
Timezone: America/Chicago
Test zenith
Using zenith: official
Date/Time: 2023-12-16 12:00:00-05:00
Sunrise: 2023-12-16 08:11:12.111139-05:00
Sunset: 2023-12-16 17:20:16.524534-05:00
Is night: False
Using zenith: civil
Date/Time: 2023-12-16 12:00:00-05:00
Sunrise: 2023-12-16 07:39:33.419425-05:00
Sunset: 2023-12-16 17:51:55.167217-05:00
Is night: False
Using zenith: nautical
Date/Time: 2023-12-16 12:00:00-05:00
Sunrise: 2023-12-16 07:04:25.491129-05:00
Sunset: 2023-12-16 18:27:03.015662-05:00
Is night: False
Using zenith: amateur
Date/Time: 2023-12-16 12:00:00-05:00
Sunrise: 2023-12-16 06:47:20.286033-05:00
Sunset: 2023-12-16 18:44:08.169022-05:00
Is night: False
Using zenith: astronomical
Date/Time: 2023-12-16 12:00:00-05:00
Sunrise: 2023-12-16 06:30:29.951023-05:00
Sunset: 2023-12-16 19:00:39.782789-05:00
Is night: False
Test 24 hours for every 20 minutes.
...
Metadata
Release files for sunrisesunset 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sunrisesunset-1.0.2.tar.gz | 6.9 kB | Without provenance | Details for sunrisesunset-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sunrisesunset-1.0.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for sunrisesunset-1.0.2-py2.py3-none-any.whl |
Total release size: 14.0 kB
Release files / sunrisesunset-1.0.2.tar.gz
| Download URL | sunrisesunset-1.0.2.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
533f12c04169c45eaa7e2e020c56b8f39a51936caa42c345bddf02331c61b16e
|
|
BLAKE2b-256 checksum How to use checksums |
c9f767f4784bb0fb0d11df57a6eef0134e980cf54241fa3b26c8ac1d6c4ee4e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / sunrisesunset-1.0.2-py2.py3-none-any.whl
| Download URL | sunrisesunset-1.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
14c3dd6acec8368236419117081c2e17edc15b8892455fe7009aace6cf092505
|
|
BLAKE2b-256 checksum How to use checksums |
2788a255cd052c220356410083ce1d0b81ece49c124610108869542183712c55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for sunrisesunset 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.