Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support timezones #11434

Merged
merged 4 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix previews loading
  • Loading branch information
NickM-27 committed May 19, 2024
commit 2d03c152fd6b7ddda45532ec6110615eedd6ed5c
6 changes: 0 additions & 6 deletions web/src/components/player/dynamic/DynamicVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ export default function DynamicVideoPlayer({
const apiHost = useApiHost();
const { data: config } = useSWR<FrigateConfig>("config");

useEffect(() => {
console.log(
`the time range is ${new Date(timeRange.after * 1000)} -> ${new Date(timeRange.before * 1000)}`,
);
}, [timeRange]);

// controlling playback

const playerRef = useRef<HTMLVideoElement | null>(null);
Expand Down
7 changes: 5 additions & 2 deletions web/src/pages/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ReviewSeverity,
ReviewSummary,
} from "@/types/review";
import { getUTCOffset } from "@/utils/dateUtil";
import EventView from "@/views/events/EventView";
import { RecordingView } from "@/views/events/RecordingView";
import axios from "axios";
Expand Down Expand Up @@ -166,15 +167,17 @@ export default function Events() {
return undefined;
}

const timezoneMinuteOffset = (getUTCOffset(new Date()) % 60) * 60;

const startDate = new Date();
startDate.setMinutes(0, 0, 0);

const endDate = new Date(reviews.at(-1)?.end_time || 0);
endDate.setHours(0, 0, 0, 0);

return {
after: startDate.getTime() / 1000,
before: endDate.getTime() / 1000,
after: startDate.getTime() / 1000 + timezoneMinuteOffset,
before: endDate.getTime() / 1000 + timezoneMinuteOffset,
};
}, [reviews]);

Expand Down
7 changes: 0 additions & 7 deletions web/src/views/events/RecordingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ export function RecordingView({
() => getChunkedTimeDay(timeRange),
[timeRange],
);
useEffect(() => {
chunkedTimeRange.forEach((c) =>
console.log(
`the chunk is ${new Date(c.after * 1000)} -> ${new Date(c.before * 1000)}`,
),
);
}, [chunkedTimeRange]);
const [selectedRangeIdx, setSelectedRangeIdx] = useState(
chunkedTimeRange.findIndex((chunk) => {
return chunk.after <= startTime && chunk.before >= startTime;
Expand Down