twenty / packages /twenty-shared /src /utils /date /getValidTimeZoneOrUndefined.ts
Jules
Initial clean CRM deployment with prebuilt assets
d9494a5
Raw
History Blame Contribute Delete
375 Bytes
import { isNonEmptyString } from '@sniptt/guards';
export const getValidTimeZoneOrUndefined = (
timeZone: string | null | undefined,
): string | undefined => {
if (!isNonEmptyString(timeZone) || timeZone === 'system') {
return undefined;
}
try {
new Intl.DateTimeFormat('en-US', { timeZone });
return timeZone;
} catch {
return undefined;
}
};