Fix timezones in Environment Canada hourly forecasts (#51917)
This commit is contained in:
parent
90e9216e9a
commit
594bcbcf7a
1 changed files with 9 additions and 8 deletions
|
@ -232,19 +232,20 @@ def get_forecast(ec_data, forecast_type):
|
|||
)
|
||||
|
||||
elif forecast_type == "hourly":
|
||||
hours = ec_data.hourly_forecasts
|
||||
for hour in range(0, 24):
|
||||
for hour in ec_data.hourly_forecasts:
|
||||
forecast_array.append(
|
||||
{
|
||||
ATTR_FORECAST_TIME: dt.as_local(
|
||||
datetime.datetime.strptime(hours[hour]["period"], "%Y%m%d%H%M")
|
||||
).isoformat(),
|
||||
ATTR_FORECAST_TEMP: int(hours[hour]["temperature"]),
|
||||
ATTR_FORECAST_TIME: datetime.datetime.strptime(
|
||||
hour["period"], "%Y%m%d%H%M%S"
|
||||
)
|
||||
.replace(tzinfo=dt.UTC)
|
||||
.isoformat(),
|
||||
ATTR_FORECAST_TEMP: int(hour["temperature"]),
|
||||
ATTR_FORECAST_CONDITION: icon_code_to_condition(
|
||||
int(hours[hour]["icon_code"])
|
||||
int(hour["icon_code"])
|
||||
),
|
||||
ATTR_FORECAST_PRECIPITATION_PROBABILITY: int(
|
||||
hours[hour]["precip_probability"]
|
||||
hour["precip_probability"]
|
||||
),
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue