handle timezones with partial hour offsets (#5115)

* handle timezones with partial hour offsets

* cleanup
This commit is contained in:
Blake Blackshear
2023-01-16 17:17:03 -06:00
committed by GitHub
parent 81b3fdb423
commit 3bec28ffef
2 changed files with 43 additions and 20 deletions

View File

@@ -14,12 +14,13 @@ from abc import ABC, abstractmethod
from collections import Counter
from collections.abc import Mapping
from multiprocessing import shared_memory
from typing import Any, AnyStr
from typing import Any, AnyStr, Tuple
import cv2
import numpy as np
import os
import psutil
import pytz
from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS
@@ -1040,3 +1041,14 @@ class SharedMemoryFrameManager(FrameManager):
self.shm_store[name].close()
self.shm_store[name].unlink()
del self.shm_store[name]
def get_tz_modifiers(tz_name: str) -> Tuple[str, str]:
seconds_offset = (
datetime.datetime.now(pytz.timezone(tz_name)).utcoffset().total_seconds()
)
hours_offset = int(seconds_offset / 60 / 60)
minutes_offset = int(seconds_offset / 60 - hours_offset * 60)
hour_modifier = f"{hours_offset} hour"
minute_modifier = f"{minutes_offset} minute"
return hour_modifier, minute_modifier