Skip to content

Commit

Permalink
Added timezonefinder so there is no need to know your exact timezone.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnobile2012 committed Dec 16, 2023
1 parent 03515ba commit 04ffadb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 7 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ Basic Usage
print(f" Sunset: {set_time}")
print(f" Is night: {rs.is_night()}\n")
Renning Test
============
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. Finally enter the timezone.
month, and day needs to be entered.

.. code-block:: console
Expand All @@ -58,7 +61,7 @@ month, and day needs to be entered. Finally enter the timezone.
Enter a address: Chicago
Chicago, Cook County, Illinois, United States
Enter date in ISO format (yyyy-mm-dd hh:mm:ss): 2023-12-16 12
Enter timezone: EST
Timezone: America/Chicago
Test zenith
Using zenith: official
Date/Time: 2023-12-16 12:00:00-05:00
Expand Down
1 change: 1 addition & 0 deletions requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

pytz
geopy
timezonefinder
#Sphinx
#sphinx_rtd_theme

Expand Down
5 changes: 4 additions & 1 deletion sunrisesunset/sunrisesunset.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def __get_rise_set(date, lat=35.9513, lon=-83.9142, zenith='official'):
import sys, pytz
#from pprint import pprint
from geopy.geocoders import Nominatim
from timezonefinder import TimezoneFinder

ret = 1
geolocator = Nominatim(user_agent='sunrisesunset')
Expand All @@ -242,7 +243,9 @@ def __get_rise_set(date, lat=35.9513, lon=-83.9142, zenith='official'):
lon = float(raw['lon'])
#pprint(raw)
date = input('Enter date in ISO format (yyyy-mm-dd hh:mm:ss): ')
tz = input('Enter timezone: ')
tf = TimezoneFinder()
tz = tf.timezone_at(lng=lon, lat=lat)
print(f"Timezone: {tz}")

try:
zone = pytz.timezone(tz)
Expand Down

0 comments on commit 04ffadb

Please sign in to comment.