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":
|
elif forecast_type == "hourly":
|
||||||
hours = ec_data.hourly_forecasts
|
for hour in ec_data.hourly_forecasts:
|
||||||
for hour in range(0, 24):
|
|
||||||
forecast_array.append(
|
forecast_array.append(
|
||||||
{
|
{
|
||||||
ATTR_FORECAST_TIME: dt.as_local(
|
ATTR_FORECAST_TIME: datetime.datetime.strptime(
|
||||||
datetime.datetime.strptime(hours[hour]["period"], "%Y%m%d%H%M")
|
hour["period"], "%Y%m%d%H%M%S"
|
||||||
).isoformat(),
|
)
|
||||||
ATTR_FORECAST_TEMP: int(hours[hour]["temperature"]),
|
.replace(tzinfo=dt.UTC)
|
||||||
|
.isoformat(),
|
||||||
|
ATTR_FORECAST_TEMP: int(hour["temperature"]),
|
||||||
ATTR_FORECAST_CONDITION: icon_code_to_condition(
|
ATTR_FORECAST_CONDITION: icon_code_to_condition(
|
||||||
int(hours[hour]["icon_code"])
|
int(hour["icon_code"])
|
||||||
),
|
),
|
||||||
ATTR_FORECAST_PRECIPITATION_PROBABILITY: int(
|
ATTR_FORECAST_PRECIPITATION_PROBABILITY: int(
|
||||||
hours[hour]["precip_probability"]
|
hour["precip_probability"]
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue