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:
Josh Hawkins
2025-05-15 17:13:32 -05:00
committed by GitHub
parent f48356cbee
commit 2f9b373c1a
5 changed files with 74 additions and 25 deletions

View File

@@ -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}`;
}