mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-12 22:25:24 +03:00
* Add basic search page * Abstract filters to separate components * Make searching functional * Add loading and no results indicators * Implement searching * Combine account and settings menus on mobile * Support using thumbnail for in progress detections * Fetch previews * Move recordings view and open recordings when search is selected * Implement detail pane * Implement saving of description * Implement similarity search * Fix clicking * Add date range picker * Fix * Fix iOS zoom bug * Mobile fixes * Use text area * Fix spacing for drawer * Fix fetching previews incorrectly
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { FrigateConfig } from "@/types/frigateConfig";
|
|
import { formatUnixTimestampToDateTime } from "@/utils/dateUtil";
|
|
import { useMemo } from "react";
|
|
|
|
export function useFormattedTimestamp(timestamp: number, format: string) {
|
|
const formattedTimestamp = useMemo(() => {
|
|
return formatUnixTimestampToDateTime(timestamp, {
|
|
strftime_fmt: format,
|
|
});
|
|
}, [format, timestamp]);
|
|
|
|
return formattedTimestamp;
|
|
}
|
|
|
|
export function useFormattedRange(start: number, end: number, format: string) {
|
|
const formattedStart = useMemo(() => {
|
|
return formatUnixTimestampToDateTime(start, {
|
|
strftime_fmt: format,
|
|
});
|
|
}, [format, start]);
|
|
const formattedEnd = useMemo(() => {
|
|
return formatUnixTimestampToDateTime(end, {
|
|
strftime_fmt: format,
|
|
});
|
|
}, [format, end]);
|
|
|
|
return `${formattedStart} - ${formattedEnd}`;
|
|
}
|
|
|
|
export function useTimezone(config: FrigateConfig | undefined) {
|
|
return useMemo(() => {
|
|
if (!config) {
|
|
return undefined;
|
|
}
|
|
|
|
return (
|
|
config.ui?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
);
|
|
}, [config]);
|
|
}
|