Skip to content

The open alternative to Salesforce, designed for AI.

375 B
Raw Blame
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;
  }
};