forked from Github/frigate
Fix timezone conversion logic (#11444)
* Fix timezone conversion logic * Use function for consistency * Cleanup
This commit is contained in:
@@ -10,7 +10,7 @@ import useSWR from "swr";
|
||||
import { FrigateConfig } from "@/types/frigateConfig";
|
||||
import { Preview } from "@/types/preview";
|
||||
import { PreviewPlayback } from "@/types/playback";
|
||||
import { getUTCOffset, isCurrentHour } from "@/utils/dateUtil";
|
||||
import { getTimestampOffset, isCurrentHour } from "@/utils/dateUtil";
|
||||
import { baseUrl } from "@/api/baseUrl";
|
||||
import { isAndroid, isChrome, isMobile } from "react-device-detect";
|
||||
import { TimeRange } from "@/types/timeline";
|
||||
@@ -41,8 +41,7 @@ export default function PreviewPlayer({
|
||||
const [currentHourFrame, setCurrentHourFrame] = useState<string>();
|
||||
|
||||
const currentPreview = useMemo(() => {
|
||||
const timeRangeOffset =
|
||||
(getUTCOffset(new Date(timeRange.before * 1000)) % 60) * 60;
|
||||
const timeRangeOffset = getTimestampOffset(timeRange.before);
|
||||
|
||||
return cameraPreviews.find(
|
||||
(preview) =>
|
||||
@@ -233,8 +232,8 @@ function PreviewVideoPlayer({
|
||||
return;
|
||||
}
|
||||
|
||||
const timeRangeOffset =
|
||||
getUTCOffset(new Date(timeRange.before * 1000)) % 60;
|
||||
// account for minutes offset in timezone
|
||||
const timeRangeOffset = getTimestampOffset(timeRange.before);
|
||||
|
||||
const preview = cameraPreviews.find(
|
||||
(preview) =>
|
||||
|
||||
@@ -12,7 +12,7 @@ import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||
import { VideoResolutionType } from "@/types/live";
|
||||
import axios from "axios";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { getUTCOffset } from "@/utils/dateUtil";
|
||||
import { getTimestampOffset } from "@/utils/dateUtil";
|
||||
|
||||
/**
|
||||
* Dynamically switches between video playback and scrubbing preview player.
|
||||
@@ -149,8 +149,7 @@ export default function DynamicVideoPlayer({
|
||||
// state of playback player
|
||||
|
||||
const recordingParams = useMemo(() => {
|
||||
const timeRangeOffset =
|
||||
(getUTCOffset(new Date(timeRange.before * 1000)) % 60) * 60;
|
||||
const timeRangeOffset = getTimestampOffset(timeRange.before);
|
||||
|
||||
return {
|
||||
before: timeRange.before + timeRangeOffset,
|
||||
|
||||
Reference in New Issue
Block a user