From da1b7c2e285e1f04b89eb90e745a7a16c9a557de Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 30 Dec 2022 16:51:13 -0700 Subject: [PATCH] Fix handling of timezones (#4831) --- frigate/http.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frigate/http.py b/frigate/http.py index a469709b8..ce7e3338c 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -1095,11 +1095,17 @@ def vod_hour_no_timezone(year_month, day, hour, camera_name): # TODO make this nicer when vod module is removed @bp.route("/vod/////") def vod_hour(year_month, day, hour, camera_name, tz_name): - tz_name = tz_name.replace(",", "/") + tz_offset = int( + datetime.now(pytz.timezone(tz_name.replace(",", "/"))) + .utcoffset() + .total_seconds() + / 60 + / 60 + ) parts = year_month.split("-") start_date = datetime( - int(parts[0]), int(parts[1]), int(day), int(hour), tzinfo=pytz.timezone(tz_name) - ).astimezone(timezone.utc) + int(parts[0]), int(parts[1]), int(day), int(hour), tzinfo=timezone.utc + ) - timedelta(hours=tz_offset) end_date = start_date + timedelta(hours=1) - timedelta(milliseconds=1) start_ts = start_date.timestamp() end_ts = end_date.timestamp()