Handle timezone
This commit is contained in:
parent
560dd5f7a8
commit
9e15da095b
2 changed files with 11 additions and 5 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue