mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Don't fail when tz is incorrect (#8723)
* Don't fail when tz is incorrect * Fix import
This commit is contained in:
parent
1dc42d2904
commit
18062eca06
@ -16,6 +16,7 @@ import pytz
|
|||||||
import yaml
|
import yaml
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone
|
||||||
|
from zoneinfo import ZoneInfoNotFoundError
|
||||||
|
|
||||||
from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS
|
from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS
|
||||||
|
|
||||||
@ -266,7 +267,16 @@ def find_by_key(dictionary, target_key):
|
|||||||
|
|
||||||
def get_tomorrow_at_time(hour: int) -> datetime.datetime:
|
def get_tomorrow_at_time(hour: int) -> datetime.datetime:
|
||||||
"""Returns the datetime of the following day at 2am."""
|
"""Returns the datetime of the following day at 2am."""
|
||||||
|
try:
|
||||||
tomorrow = datetime.datetime.now(get_localzone()) + datetime.timedelta(days=1)
|
tomorrow = datetime.datetime.now(get_localzone()) + datetime.timedelta(days=1)
|
||||||
|
except ZoneInfoNotFoundError:
|
||||||
|
tomorrow = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
|
||||||
|
days=1
|
||||||
|
)
|
||||||
|
logger.warning(
|
||||||
|
"Using utc for maintenance due to missing or incorrect timezone set"
|
||||||
|
)
|
||||||
|
|
||||||
return tomorrow.replace(hour=hour, minute=0, second=0).astimezone(
|
return tomorrow.replace(hour=hour, minute=0, second=0).astimezone(
|
||||||
datetime.timezone.utc
|
datetime.timezone.utc
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user