Skip to main content

Simple sunset and sunrise time calculation python library

Project description

SunTime

Simple sunset and sunrise time calculation python library forked from pypi suntime library.

Usage

You can use the library to get UTC and local time sunrise and sunset times typing:

from suntime import Sun, DegreesOffset, SunTimeException

MADRID_LAT = 40.416775
MADRID_LON = -3.703790

madrid_sun = Sun(MADRID_LAT, MADRID_LON)

# Get today's sunrise and sunset in UTC
sunrise_madrid = madrid_sun.get_sunrise_time()

today_ss = sun.get_sunset_time()
today_sr = sun.get_local_sunset_time()
print('Today at Madrid the sun raised at {} and get down at {} UTC'.
      format(today_sr.strftime('%H:%M'), today_ss.strftime('%H:%M')))

# On a special date in your machine's local time zone
abd = datetime.date(2014, 10, 3)
abd_sr = sun.get_local_sunrise_time(abd)
abd_ss = sun.get_local_sunset_time(abd)
print('On {} the sun at Madrid raised at {} and get down at {}.'.
      format(abd, abd_sr.strftime('%H:%M'), abd_ss.strftime('%H:%M')))

# offsets
horizon = madrid_sun.get_local_sunset_time(
    degrees_offset=DegreesOffset.horizon.value) # 0

civil = madrid_sun.get_local_sunset_time(
    degrees_offset=DegreesOffset.civil.value) # 6

nautical = madrid_sun.get_local_sunset_time(
    degrees_offset=DegreesOffset.nautilcal.value) # 12

astronomical = madrid_sun.get_local_sunset_time(
    degrees_offset=DegreesOffset.astronomical.value) # 18

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dt-suntime-1.0.0.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

dt_suntime-1.0.0-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page