Files
calendar/apps/web/modules/data-table/hooks/useChangeTimeZoneWithPreservedLocalTime.ts
T
Eunjae LeeGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1368ffe55d refactor: move data-table hooks/contexts/provider from features to web modules (#27833)
* refactor: move data-table hooks/contexts/provider from features to web modules

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: update broken useColumnResizing import path in DataTable.tsx

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: update remaining broken import paths for moved hooks

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* docs: update GUIDE.md import paths and file references for moved modules

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-02-13 00:00:40 +09:00

21 lines
773 B
TypeScript

import { useMemo } from "react";
import { CURRENT_TIMEZONE } from "@calcom/lib/timezoneConstants";
import { preserveLocalTime } from "@calcom/features/data-table/lib/preserveLocalTime";
import { useDataTable } from "./useDataTable";
/**
* Converts a timestamp to maintain the same local time in a different timezone.
* Fore more info, read packages/features/data-table/lib/preserveLocalTime.ts
*/
export function useChangeTimeZoneWithPreservedLocalTime(isoString: string) {
const { timeZone: profileTimeZone } = useDataTable();
return useMemo(() => {
if (!profileTimeZone || CURRENT_TIMEZONE === profileTimeZone) {
return isoString;
}
return preserveLocalTime(isoString, CURRENT_TIMEZONE, profileTimeZone);
}, [isoString, profileTimeZone]);
}