mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-19 23:08:08 +02:00
Improve timezone handling (#18257)
* Ensure review activity calendar uses correct timezone react-day-picker 9.x adds a timeZone prop and a TZDate() handler to show the calendar based on a timezone and better handle dates passed to it in timezones * Ensure calendar range uses correct timezone * clean up * ensure range is timezone aware * ensure export dates are timezone aware
This commit is contained in:
@@ -21,22 +21,29 @@ export function useFormattedTimestamp(
|
||||
return formattedTimestamp;
|
||||
}
|
||||
|
||||
export function useFormattedRange(start: number, end: number, format: string) {
|
||||
export function useFormattedRange(
|
||||
start: number,
|
||||
end: number,
|
||||
format: string,
|
||||
timezone?: string,
|
||||
) {
|
||||
const locale = useDateLocale();
|
||||
|
||||
const formattedStart = useMemo(() => {
|
||||
return formatUnixTimestampToDateTime(start, {
|
||||
timezone,
|
||||
date_format: format,
|
||||
locale,
|
||||
});
|
||||
}, [format, start, locale]);
|
||||
}, [format, start, timezone, locale]);
|
||||
|
||||
const formattedEnd = useMemo(() => {
|
||||
return formatUnixTimestampToDateTime(end, {
|
||||
timezone,
|
||||
date_format: format,
|
||||
locale,
|
||||
});
|
||||
}, [format, end, locale]);
|
||||
}, [format, end, timezone, locale]);
|
||||
|
||||
return `${formattedStart} - ${formattedEnd}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user