Handle timezone

This commit is contained in:
nemunaire 2022-08-12 12:48:39 +02:00
commit 9e15da095b
2 changed files with 11 additions and 5 deletions

View file

@ -151,6 +151,12 @@ class DarkSkyAPI:
def get_alerts(self, *args, **kwargs):
return self.get_weather(*args, **kwargs)["alerts"]
def read_timestamp(self, timestamp, *args, **kwargs):
wth = self.get_weather(*args, **kwargs)
tz = timezone(timedelta(hours=wth["offset"]), wth["timezone"])
return datetime.fromtimestamp(timestamp, tz=tz)
WeatherAPI = DarkSkyAPI