Use UTC for recordings (#4656)

* Write files in UTC and update folder structure to not conflict

* Add timezone arg for events summary

* Fixes for timezone in calls

* Use timezone for recording and recordings summary endpoints

* Fix sqlite parsing

* Fix sqlite parsing

* Fix recordings summary with timezone

* Fix

* Formatting

* Add pytz

* Fix default timezone

* Add note about times being displayed in localtime

* Improve timezone wording and show actual timezone

* Add alternate endpoint to cover existing usecase to avoid breaking change

* Formatting
This commit is contained in:
Nicolas Mowen
2022-12-11 06:45:32 -07:00
committed by GitHub
parent 739a267462
commit 037f3761e7
4 changed files with 55 additions and 17 deletions

View File

@@ -261,8 +261,8 @@ class RecordingMaintainer(threading.Thread):
def store_segment(
self,
camera,
start_time,
end_time,
start_time: datetime.datetime,
end_time: datetime.datetime,
duration,
cache_path,
store_mode: RetainModeEnum,
@@ -277,12 +277,20 @@ class RecordingMaintainer(threading.Thread):
self.end_time_cache.pop(cache_path, None)
return
directory = os.path.join(RECORD_DIR, start_time.strftime("%Y-%m/%d/%H"), camera)
directory = os.path.join(
RECORD_DIR,
start_time.replace(tzinfo=datetime.timezone.utc)
.astimezone(tz=None)
.strftime("%Y-%m-%d/%H"),
camera,
)
if not os.path.exists(directory):
os.makedirs(directory)
file_name = f"{start_time.strftime('%M.%S.mp4')}"
file_name = (
f"{start_time.replace(tzinfo=datetime.timezone.utc).strftime('%M.%S.mp4')}"
)
file_path = os.path.join(directory, file_name)
try: