diff --git a/homeassistant/components/environment_canada/weather.py b/homeassistant/components/environment_canada/weather.py index 5301843fc0a..a4a8a02cee9 100644 --- a/homeassistant/components/environment_canada/weather.py +++ b/homeassistant/components/environment_canada/weather.py @@ -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"] ), } )