Skip to content

Commit

Permalink
Fix timezone for HA 2021.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jcwillox committed Jun 4, 2021
1 parent 180158b commit aa53cd2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions custom_components/auto_backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@

import aiohttp
import async_timeout
import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from aiohttp import ClientSession
from homeassistant.config_entries import ConfigEntry, SOURCE_IMPORT
from homeassistant.core import HomeAssistant
from slugify import slugify

import homeassistant.helpers.config_validation as cv
from homeassistant.components.hassio import (
SERVICE_SNAPSHOT_FULL,
SERVICE_SNAPSHOT_PARTIAL,
Expand All @@ -26,10 +22,15 @@
)
from homeassistant.components.hassio.const import X_HASSIO
from homeassistant.components.hassio.handler import HassioAPIError
from homeassistant.config_entries import ConfigEntry, SOURCE_IMPORT
from homeassistant.const import ATTR_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.json import JSONEncoder
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceCallType
from homeassistant.util import dt as dt_util
from slugify import slugify

from .const import (
DOMAIN,
EVENT_SNAPSHOT_FAILED,
Expand Down Expand Up @@ -299,9 +300,10 @@ async def new_snapshot(self, data, full=False):
"""Create a new snapshot in Hass.io."""
if ATTR_NAME not in data:
# provide a default name if none was supplied.
data[ATTR_NAME] = datetime.now(self._hass.config.time_zone).strftime(
"%A, %b %d, %Y"
)
time_zone = self._hass.config.time_zone
if isinstance(time_zone, str):
time_zone = dt_util.get_time_zone(time_zone)
data[ATTR_NAME] = datetime.now(time_zone).strftime("%A, %b %d, %Y")

_LOGGER.debug("Creating snapshot %s", data[ATTR_NAME])

Expand Down

0 comments on commit aa53cd2

Please sign in to comment.