Simple Python code that outputs the local sunset and sunrise time at your location on a given date.
- You'll need to get an API key from Google Maps Platform to use Google's Geocode and Timezone APIs.
- I used the Sunrise-Sunset API to obtain the sunrise/sunset times for a given latitude, longitude, and date.
- Open up a terminal and navigate to the directory the file is saved in.
- Then call:
python3 SunsetSunriseData.py
. - You'll be prompted for a location and a date.
- Your sunrise and sunset times will be outputed in the terminal.
- The user inputs a location and date.
- The Geocode API translates the location to a latitude and longitude.
- These latitude and longitude coordinates along with the date are used to determine the sunrise/sunset times.
- The Timezone API also uses latitude, longitude, and date to determine the location's timezone.
- Finally, the times are converted from UTC to local time and outputed to the console.