forked from Github/frigate
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:
@@ -9,13 +9,16 @@ import { useApiHost } from '../api';
|
||||
import useSWR from 'swr';
|
||||
|
||||
export default function Recording({ camera, date, hour = '00', minute = '00', second = '00' }) {
|
||||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const currentDate = useMemo(
|
||||
() => (date ? parseISO(`${date}T${hour || '00'}:${minute || '00'}:${second || '00'}`) : new Date()),
|
||||
[date, hour, minute, second]
|
||||
);
|
||||
|
||||
const apiHost = useApiHost();
|
||||
const { data: recordingsSummary } = useSWR(`${camera}/recordings/summary`, { revalidateOnFocus: false });
|
||||
const { data: recordingsSummary } = useSWR([`${camera}/recordings/summary`, { timezone }], {
|
||||
revalidateOnFocus: false,
|
||||
});
|
||||
|
||||
const recordingParams = {
|
||||
before: getUnixTime(endOfHour(currentDate)),
|
||||
@@ -66,14 +69,17 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se
|
||||
description: `${camera} recording @ ${h.hour}:00.`,
|
||||
sources: [
|
||||
{
|
||||
src: `${apiHost}/vod/${year}-${month}/${day}/${h.hour}/${camera}/master.m3u8`,
|
||||
src: `${apiHost}/vod/${year}-${month}/${day}/${h.hour}/${camera}/${timezone.replaceAll(
|
||||
'/',
|
||||
'_'
|
||||
)}/master.m3u8`,
|
||||
type: 'application/vnd.apple.mpegurl',
|
||||
},
|
||||
],
|
||||
};
|
||||
})
|
||||
.reverse();
|
||||
}, [apiHost, date, recordingsSummary, camera]);
|
||||
}, [apiHost, date, recordingsSummary, camera, timezone]);
|
||||
|
||||
const playlistIndex = useMemo(() => {
|
||||
const index = playlist.findIndex((item) => item.name === hour);
|
||||
@@ -126,6 +132,7 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se
|
||||
return (
|
||||
<div className="space-y-4 p-2 px-4">
|
||||
<Heading>{camera.replaceAll('_', ' ')} Recordings</Heading>
|
||||
<div className="text-xs">Dates and times are based on the browser's timezone {timezone}</div>
|
||||
|
||||
<VideoPlayer
|
||||
onReady={(player) => {
|
||||
|
||||
Reference in New Issue
Block a user