update deps (#6093)

* update dev deps

* update deps

* docs deps

* python dev deps

* update python deps
This commit is contained in:
Blake Blackshear 2023-04-15 14:17:59 -05:00 committed by GitHub
parent a218d2f6ff
commit 15415bab10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 2467 additions and 2715 deletions

1365
docs/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,12 +14,12 @@
"write-heading-ids": "docusaurus write-heading-ids" "write-heading-ids": "docusaurus write-heading-ids"
}, },
"dependencies": { "dependencies": {
"@docusaurus/core": "^2.2.0", "@docusaurus/core": "^2.4.0",
"@docusaurus/preset-classic": "^2.2.0", "@docusaurus/preset-classic": "^2.4.0",
"@mdx-js/react": "^1.6.22", "@mdx-js/react": "^1.6.22",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"raw-loader": "^4.0.2",
"prism-react-renderer": "^1.3.5", "prism-react-renderer": "^1.3.5",
"raw-loader": "^4.0.2",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2" "react-dom": "^17.0.2"
}, },
@ -36,8 +36,8 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^17.0.0", "@docusaurus/module-type-aliases": "^2.4.0",
"@docusaurus/module-type-aliases": "2.2.0" "@types/react": "^17.0.0"
}, },
"engines": { "engines": {
"node": ">=16.14" "node": ">=16.14"

View File

@ -391,7 +391,6 @@ class FrigateApp:
self.start_stats_emitter() self.start_stats_emitter()
self.start_watchdog() self.start_watchdog()
self.check_shm() self.check_shm()
# self.zeroconf = broadcast_zeroconf(self.config.mqtt.client_id)
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None: def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
self.stop() self.stop()

View File

@ -59,6 +59,3 @@ ignore_errors = false
[mypy-frigate.watchdog] [mypy-frigate.watchdog]
ignore_errors = false ignore_errors = false
disallow_untyped_calls = false disallow_untyped_calls = false
[mypy-frigate.zeroconf]
ignore_errors = false

View File

@ -329,7 +329,6 @@ class BirdsEyeFrameManager:
# update each position in the layout # update each position in the layout
for position, camera in enumerate(self.camera_layout, start=0): for position, camera in enumerate(self.camera_layout, start=0):
# if this camera was removed, replace it or clear it # if this camera was removed, replace it or clear it
if camera in removed_cameras: if camera in removed_cameras:
# if replacing this camera with a newly added one # if replacing this camera with a newly added one

View File

@ -111,7 +111,6 @@ class RecordingMaintainer(threading.Thread):
grouped_recordings[camera] = grouped_recordings[camera][-keep_count:] grouped_recordings[camera] = grouped_recordings[camera][-keep_count:]
for camera, recordings in grouped_recordings.items(): for camera, recordings in grouped_recordings.items():
# clear out all the recording info for old frames # clear out all the recording info for old frames
while ( while (
len(self.recordings_info[camera]) > 0 len(self.recordings_info[camera]) > 0

View File

@ -23,7 +23,6 @@ logger = logging.getLogger(__name__)
def get_latest_version(config: FrigateConfig) -> str: def get_latest_version(config: FrigateConfig) -> str:
if not config.telemetry.version_check: if not config.telemetry.version_check:
return "disabled" return "disabled"

View File

@ -179,7 +179,6 @@ class StorageMaintainer(threading.Thread):
def run(self): def run(self):
"""Check every 5 minutes if storage needs to be cleaned up.""" """Check every 5 minutes if storage needs to be cleaned up."""
while not self.stop_event.wait(300): while not self.stop_event.wait(300):
if not self.camera_storage_stats or True in [ if not self.camera_storage_stats or True in [
r["needs_refresh"] for r in self.camera_storage_stats.values() r["needs_refresh"] for r in self.camera_storage_stats.values()
]: ]:

View File

@ -673,7 +673,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].detect.max_disappeared == 5 * 5 assert runtime_config.cameras["back"].detect.max_disappeared == 5 * 5
def test_motion_frame_height_wont_go_below_120(self): def test_motion_frame_height_wont_go_below_120(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -702,7 +701,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].motion.frame_height == 50 assert runtime_config.cameras["back"].motion.frame_height == 50
def test_motion_contour_area_dynamic(self): def test_motion_contour_area_dynamic(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -731,7 +729,6 @@ class TestConfig(unittest.TestCase):
assert round(runtime_config.cameras["back"].motion.contour_area) == 30 assert round(runtime_config.cameras["back"].motion.contour_area) == 30
def test_merge_labelmap(self): def test_merge_labelmap(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"model": {"labelmap": {7: "truck"}}, "model": {"labelmap": {7: "truck"}},
@ -761,7 +758,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.model.merged_labelmap[7] == "truck" assert runtime_config.model.merged_labelmap[7] == "truck"
def test_default_labelmap_empty(self): def test_default_labelmap_empty(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -790,7 +786,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.model.merged_labelmap[0] == "person" assert runtime_config.model.merged_labelmap[0] == "person"
def test_default_labelmap(self): def test_default_labelmap(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"model": {"width": 320, "height": 320}, "model": {"width": 320, "height": 320},
@ -820,7 +815,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.model.merged_labelmap[0] == "person" assert runtime_config.model.merged_labelmap[0] == "person"
def test_fails_on_invalid_role(self): def test_fails_on_invalid_role(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -849,7 +843,6 @@ class TestConfig(unittest.TestCase):
self.assertRaises(ValidationError, lambda: FrigateConfig(**config)) self.assertRaises(ValidationError, lambda: FrigateConfig(**config))
def test_fails_on_missing_role(self): def test_fails_on_missing_role(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -880,7 +873,6 @@ class TestConfig(unittest.TestCase):
self.assertRaises(ValueError, lambda: frigate_config.runtime_config) self.assertRaises(ValueError, lambda: frigate_config.runtime_config)
def test_works_on_missing_role_multiple_cams(self): def test_works_on_missing_role_multiple_cams(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -929,7 +921,6 @@ class TestConfig(unittest.TestCase):
runtime_config = frigate_config.runtime_config runtime_config = frigate_config.runtime_config
def test_global_detect(self): def test_global_detect(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"detect": {"max_disappeared": 1}, "detect": {"max_disappeared": 1},
@ -959,7 +950,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].detect.height == 1080 assert runtime_config.cameras["back"].detect.height == 1080
def test_default_detect(self): def test_default_detect(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -983,7 +973,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].detect.height == 720 assert runtime_config.cameras["back"].detect.height == 720
def test_global_detect_merge(self): def test_global_detect_merge(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"detect": {"max_disappeared": 1, "height": 720}, "detect": {"max_disappeared": 1, "height": 720},
@ -1014,7 +1003,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].detect.width == 1920 assert runtime_config.cameras["back"].detect.width == 1920
def test_global_snapshots(self): def test_global_snapshots(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"snapshots": {"enabled": True}, "snapshots": {"enabled": True},
@ -1042,7 +1030,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].snapshots.height == 100 assert runtime_config.cameras["back"].snapshots.height == 100
def test_default_snapshots(self): def test_default_snapshots(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -1066,7 +1053,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].snapshots.quality == 70 assert runtime_config.cameras["back"].snapshots.quality == 70
def test_global_snapshots_merge(self): def test_global_snapshots_merge(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"snapshots": {"bounding_box": False, "height": 300}, "snapshots": {"bounding_box": False, "height": 300},
@ -1096,7 +1082,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].snapshots.enabled assert runtime_config.cameras["back"].snapshots.enabled
def test_global_rtmp_disabled(self): def test_global_rtmp_disabled(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -1119,7 +1104,6 @@ class TestConfig(unittest.TestCase):
assert not runtime_config.cameras["back"].rtmp.enabled assert not runtime_config.cameras["back"].rtmp.enabled
def test_default_not_rtmp(self): def test_default_not_rtmp(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -1142,7 +1126,6 @@ class TestConfig(unittest.TestCase):
assert not runtime_config.cameras["back"].rtmp.enabled assert not runtime_config.cameras["back"].rtmp.enabled
def test_global_rtmp_merge(self): def test_global_rtmp_merge(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"rtmp": {"enabled": False}, "rtmp": {"enabled": False},
@ -1169,7 +1152,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].rtmp.enabled assert runtime_config.cameras["back"].rtmp.enabled
def test_global_rtmp_default(self): def test_global_rtmp_default(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -1196,7 +1178,6 @@ class TestConfig(unittest.TestCase):
assert not runtime_config.cameras["back"].rtmp.enabled assert not runtime_config.cameras["back"].rtmp.enabled
def test_global_jsmpeg(self): def test_global_jsmpeg(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"live": {"quality": 4}, "live": {"quality": 4},
@ -1220,7 +1201,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].live.quality == 4 assert runtime_config.cameras["back"].live.quality == 4
def test_default_live(self): def test_default_live(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -1243,7 +1223,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].live.quality == 8 assert runtime_config.cameras["back"].live.quality == 8
def test_global_live_merge(self): def test_global_live_merge(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"live": {"quality": 4, "height": 480}, "live": {"quality": 4, "height": 480},
@ -1271,7 +1250,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].live.height == 480 assert runtime_config.cameras["back"].live.height == 480
def test_global_timestamp_style(self): def test_global_timestamp_style(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"timestamp_style": {"position": "bl"}, "timestamp_style": {"position": "bl"},
@ -1295,7 +1273,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].timestamp_style.position == "bl" assert runtime_config.cameras["back"].timestamp_style.position == "bl"
def test_default_timestamp_style(self): def test_default_timestamp_style(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"cameras": { "cameras": {
@ -1318,7 +1295,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].timestamp_style.position == "tl" assert runtime_config.cameras["back"].timestamp_style.position == "tl"
def test_global_timestamp_style_merge(self): def test_global_timestamp_style_merge(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"rtmp": {"enabled": False}, "rtmp": {"enabled": False},
@ -1345,7 +1321,6 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].timestamp_style.thickness == 4 assert runtime_config.cameras["back"].timestamp_style.thickness == 4
def test_allow_retain_to_be_a_decimal(self): def test_allow_retain_to_be_a_decimal(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"snapshots": {"retain": {"default": 1.5}}, "snapshots": {"retain": {"default": 1.5}},

View File

@ -772,7 +772,6 @@ def get_docker_memlimit_bytes() -> int:
# check running a supported cgroups version # check running a supported cgroups version
if get_cgroups_version() == "cgroup2": if get_cgroups_version() == "cgroup2":
memlimit_command = ["cat", "/sys/fs/cgroup/memory.max"] memlimit_command = ["cat", "/sys/fs/cgroup/memory.max"]
p = sp.run( p = sp.run(
@ -817,7 +816,6 @@ def get_cpu_stats() -> dict[str, dict]:
for line in lines: for line in lines:
stats = list(filter(lambda a: a != "", line.strip().split(" "))) stats = list(filter(lambda a: a != "", line.strip().split(" ")))
try: try:
if docker_memlimit > 0: if docker_memlimit > 0:
mem_res = int(stats[5]) mem_res = int(stats[5])
mem_pct = str( mem_pct = str(

View File

@ -162,7 +162,6 @@ def capture_frames(
current_frame: mp.Value, current_frame: mp.Value,
stop_event: mp.Event, stop_event: mp.Event,
): ):
frame_size = frame_shape[0] * frame_shape[1] frame_size = frame_shape[0] * frame_shape[1]
frame_rate = EventsPerSecond() frame_rate = EventsPerSecond()
frame_rate.start() frame_rate.start()
@ -594,7 +593,6 @@ def process_frames(
stop_event, stop_event,
exit_on_empty: bool = False, exit_on_empty: bool = False,
): ):
fps = process_info["process_fps"] fps = process_info["process_fps"]
detection_fps = process_info["detection_fps"] detection_fps = process_info["detection_fps"]
current_frame_time = process_info["detection_frame"] current_frame_time = process_info["detection_frame"]
@ -748,7 +746,6 @@ def process_frames(
selected_objects = [] selected_objects = []
for group in detected_object_groups.values(): for group in detected_object_groups.values():
# apply non-maxima suppression to suppress weak, overlapping bounding boxes # apply non-maxima suppression to suppress weak, overlapping bounding boxes
# o[2] is the box of the object: xmin, ymin, xmax, ymax # o[2] is the box of the object: xmin, ymin, xmax, ymax
# apply max/min to ensure values do not exceed the known frame size # apply max/min to ensure values do not exceed the known frame size

View File

@ -1,62 +0,0 @@
import logging
import socket
from zeroconf import (
ServiceInfo,
NonUniqueNameException,
InterfaceChoice,
IPVersion,
Zeroconf,
)
logger = logging.getLogger(__name__)
ZEROCONF_TYPE = "_frigate._tcp.local."
# Taken from: http://stackoverflow.com/a/11735897
def get_local_ip() -> bytes:
"""Try to determine the local IP address of the machine."""
host_ip_str = ""
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Use Google Public DNS server to determine own IP
sock.connect(("8.8.8.8", 80))
host_ip_str = sock.getsockname()[0]
except OSError:
try:
host_ip_str = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
host_ip_str = "127.0.0.1"
finally:
sock.close()
try:
host_ip_pton = socket.inet_pton(socket.AF_INET, host_ip_str)
except OSError:
host_ip_pton = socket.inet_pton(socket.AF_INET6, host_ip_str)
return host_ip_pton
def broadcast_zeroconf(frigate_id: str) -> Zeroconf:
zeroconf = Zeroconf(interfaces=InterfaceChoice.Default, ip_version=IPVersion.V4Only)
host_ip = get_local_ip()
info = ServiceInfo(
ZEROCONF_TYPE,
name=f"{frigate_id}.{ZEROCONF_TYPE}",
addresses=[host_ip],
port=5000,
)
logger.info("Starting Zeroconf broadcast")
try:
zeroconf.register_service(info)
except NonUniqueNameException:
logger.error(
"Frigate instance with identical name present in the local network"
)
return zeroconf

View File

@ -1,2 +1,2 @@
pylint == 2.15.* pylint == 2.17.*
black == 22.12.* black == 23.3.*

View File

@ -11,15 +11,14 @@ peewee_migrate == 1.6.*
psutil == 5.9.* psutil == 5.9.*
pydantic == 1.10.* pydantic == 1.10.*
PyYAML == 6.0 PyYAML == 6.0
pytz == 2022.7 pytz == 2023.3
tzlocal == 4.2 tzlocal == 4.2
types-PyYAML == 6.0.* types-PyYAML == 6.0.*
requests == 2.28.* requests == 2.28.*
types-requests == 2.28.* types-requests == 2.28.*
scipy == 1.8.* scipy == 1.10.*
setproctitle == 1.3.* setproctitle == 1.3.*
ws4py == 0.5.* ws4py == 0.5.*
zeroconf == 0.47.*
# Openvino Library - Custom built with MYRIAD support # Openvino Library - Custom built with MYRIAD support
openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.2.0/openvino-2022.2.0-000-cp39-cp39-manylinux_2_31_x86_64.whl; platform_machine == 'x86_64' openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.2.0/openvino-2022.2.0-000-cp39-cp39-manylinux_2_31_x86_64.whl; platform_machine == 'x86_64'
openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.2.0/openvino-2022.2.0-000-cp39-cp39-linux_aarch64.whl; platform_machine == 'aarch64' openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.2.0/openvino-2022.2.0-000-cp39-cp39-linux_aarch64.whl; platform_machine == 'aarch64'

3640
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,21 +13,21 @@
}, },
"dependencies": { "dependencies": {
"@cycjimmy/jsmpeg-player": "^6.0.5", "@cycjimmy/jsmpeg-player": "^6.0.5",
"axios": "^1.2.2", "axios": "^1.3.5",
"copy-to-clipboard": "3.3.3", "copy-to-clipboard": "3.3.3",
"date-fns": "^2.29.3", "date-fns": "^2.29.3",
"idb-keyval": "^6.2.0", "idb-keyval": "^6.2.0",
"immer": "^9.0.16", "immer": "^9.0.21",
"monaco-yaml": "^4.0.2", "monaco-yaml": "^4.0.4",
"preact": "^10.11.3", "preact": "^10.13.2",
"preact-async-route": "^2.2.1", "preact-async-route": "^2.2.1",
"preact-router": "^4.1.0", "preact-router": "^4.1.0",
"react": "npm:@preact/compat@^17.1.2", "react": "npm:@preact/compat@^17.1.2",
"react-dom": "npm:@preact/compat@^17.1.2", "react-dom": "npm:@preact/compat@^17.1.2",
"strftime": "^0.10.1", "strftime": "^0.10.1",
"swr": "^1.3.0", "swr": "^1.3.0",
"video.js": "^7.20.3", "video.js": "^7.21.4",
"videojs-playlist": "^5.0.0", "videojs-playlist": "^5.1.0",
"videojs-seek-buttons": "^3.0.1", "videojs-seek-buttons": "^3.0.1",
"vite-plugin-monaco-editor": "^1.1.0" "vite-plugin-monaco-editor": "^1.1.0"
}, },
@ -35,26 +35,26 @@
"@preact/preset-vite": "^2.5.0", "@preact/preset-vite": "^2.5.0",
"@tailwindcss/forms": "^0.5.3", "@tailwindcss/forms": "^0.5.3",
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@testing-library/preact": "^3.2.2", "@testing-library/preact": "^3.2.3",
"@testing-library/user-event": "^14.4.3", "@testing-library/user-event": "^14.4.3",
"@types/video.js": "^7.3.50", "@types/video.js": "^7.3.51",
"@typescript-eslint/eslint-plugin": "^5.47.1", "@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.47.1", "@typescript-eslint/parser": "^5.58.0",
"@vitest/coverage-c8": "^0.26.2", "@vitest/coverage-c8": "^0.30.1",
"@vitest/ui": "^0.26.2", "@vitest/ui": "^0.30.1",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.14",
"eslint": "^8.30.0", "eslint": "^8.38.0",
"eslint-config-preact": "^1.3.0", "eslint-config-preact": "^1.3.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.8.0",
"eslint-plugin-vitest-globals": "^1.2.0", "eslint-plugin-vitest-globals": "^1.3.1",
"fake-indexeddb": "^4.0.1", "fake-indexeddb": "^4.0.1",
"jsdom": "^20.0.3", "jsdom": "^21.1.1",
"msw": "^0.49.2", "msw": "^1.2.1",
"postcss": "^8.4.19", "postcss": "^8.4.19",
"prettier": "^2.8.0", "prettier": "^2.8.7",
"tailwindcss": "^3.2.4", "tailwindcss": "^3.3.1",
"typescript": "^4.8.4", "typescript": "^5.0.4",
"vite": "^4.0.3", "vite": "^4.2.1",
"vitest": "^0.25.3" "vitest": "^0.30.1"
} }
} }

View File

@ -125,7 +125,7 @@ const getUTCOffset = (date: Date, timezone: string): number => {
const utcDate = new Date(date.getTime() - (date.getTimezoneOffset() * 60 * 1000)); const utcDate = new Date(date.getTime() - (date.getTimezoneOffset() * 60 * 1000));
// locale of en-CA is required for proper locale format // locale of en-CA is required for proper locale format
let iso = utcDate.toLocaleString('en-CA', { timeZone: timezone, hour12: false }).replace(', ', 'T'); let iso = utcDate.toLocaleString('en-CA', { timeZone: timezone, hour12: false }).replace(', ', 'T');
iso += '.' + utcDate.getMilliseconds().toString().padStart(3, '0'); iso += `.${utcDate.getMilliseconds().toString().padStart(3, '0')}`;
const target = new Date(iso + 'Z'); const target = new Date(`${iso}Z`);
return (target.getTime() - utcDate.getTime()) / 60 / 1000; return (target.getTime() - utcDate.getTime()) / 60 / 1000;
} }