|
6 | 6 |
|
7 | 7 | from geopy.exc import GeocoderUnavailable, GeocoderTimedOut, GeocoderServiceError # type: ignore |
8 | 8 | from geopy.geocoders import Nominatim # type: ignore |
9 | | -from tzwhere import tzwhere # type: ignore |
| 9 | +from timezonefinder import TimezoneFinder # type: ignore |
10 | 10 | import backoff # type: ignore |
11 | 11 |
|
12 | 12 | from .errors import ParserError |
@@ -39,7 +39,7 @@ class Geolocator: |
39 | 39 | def timezone(cls): # pylint: disable=no-self-argument |
40 | 40 | """Load the timezone resolver.""" |
41 | 41 | if cls._timezone is None: |
42 | | - cls._timezone = tzwhere.tzwhere() |
| 42 | + cls._timezone = TimezoneFinder() |
43 | 43 | logger.info("Loaded local timezone resolver.") |
44 | 44 | return cls._timezone |
45 | 45 |
|
@@ -110,12 +110,12 @@ def city_timezone(self, city: str) -> str: |
110 | 110 | if self.timezone is not None: |
111 | 111 | try: |
112 | 112 | latitude, longitude = self.get_location(city) |
113 | | - timezone = self.timezone.tzNameAt(latitude, longitude) # pylint: disable=no-member |
| 113 | + timezone = self.timezone.timezone_at(lat=latitude, lng=longitude) # pylint: disable=no-member |
114 | 114 | if not timezone: |
115 | 115 | # In some cases, given a latitued and longitued, the tzwhere library returns |
116 | 116 | # an empty timezone, so we try with the coordinates from the API as an alternative |
117 | 117 | latitude, longitude = self.get_location_from_api(city) |
118 | | - timezone = self.timezone.tzNameAt(latitude, longitude) # pylint: disable=no-member |
| 118 | + timezone = self.timezone.timezone_at(lat=latitude, lng=longitude) # pylint: disable=no-member |
119 | 119 |
|
120 | 120 | if timezone: |
121 | 121 | logger.debug("Matched city %s to timezone %s", city, timezone) |
|
0 commit comments