History snapshot filenames use Frigate timeline timezone

(cherry picked from commit 5c3b0fb11b859a8d2b8a5c1e630d7e10b355d08b)
This commit is contained in:
nrlcode 2026-03-24 13:11:22 -07:00
parent 24b27dfa4a
commit 997f15ab9c
2 changed files with 21 additions and 3 deletions

View File

@ -369,6 +369,7 @@ export default function HlsVideoPlayer({
generateSnapshotFilename(
camera ?? "recording",
snapshotTimestamp,
config?.ui?.timezone,
),
);
toast.success(

View File

@ -1,4 +1,5 @@
import { baseUrl } from "@/api/baseUrl";
import { formatUnixTimestampToDateTime } from "@/utils/dateUtil";
type SnapshotResponse = {
dataUrl: string;
@ -97,9 +98,25 @@ export function downloadSnapshot(dataUrl: string, filename: string): void {
}
}
export function generateSnapshotFilename(cameraName: string): string {
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, -5);
return `${cameraName}_snapshot_${timestamp}.jpg`;
export function generateSnapshotFilename(
cameraName: string,
timestampSeconds?: number,
timezone?: string,
): string {
const seconds = timestampSeconds ?? Date.now() / 1000;
const timestamp = formatUnixTimestampToDateTime(seconds, {
timezone,
date_format: "yyyy-MM-dd'T'HH-mm-ss",
});
const safeTimestamp =
timestamp === "Invalid time"
? new Date(seconds * 1000)
.toISOString()
.replace(/[:.]/g, "-")
.slice(0, -5)
: timestamp;
return `${cameraName}_snapshot_${safeTimestamp}.jpg`;
}
export async function grabVideoSnapshot(): Promise<SnapshotResult> {