diff --git a/README.rst b/README.rst index 5f4aeec..4b905a7 100644 --- a/README.rst +++ b/README.rst @@ -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 @@ -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 diff --git a/requirements/development.txt b/requirements/development.txt index 6f916c0..a70e32d 100644 --- a/requirements/development.txt +++ b/requirements/development.txt @@ -3,6 +3,7 @@ pytz geopy +timezonefinder #Sphinx #sphinx_rtd_theme diff --git a/sunrisesunset/sunrisesunset.py b/sunrisesunset/sunrisesunset.py index dfeff46..e8e644b 100644 --- a/sunrisesunset/sunrisesunset.py +++ b/sunrisesunset/sunrisesunset.py @@ -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') @@ -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)