export function toDateOrNull(v?: string | null): Date | null {
  if (!v) return null;
  const day = new Date(v);
  return isNaN(day.getTime()) ? null : day;
}
export function toDateOrUndefined(v?: string | null): Date | undefined {
  const day = toDateOrNull(v ?? undefined);
  return day === null ? undefined : day;
}

export function toCompanyCodeFromString(company_name: string) {
  let company_code = 271585;
  if (company_name === 'Targo') {
    company_code = 271583;
  }
  return company_code;
}

export function toStringFromCompanyCode(company_code: number) {
  let company_name = 'Solucom';
  if (company_code === 271583) {
    company_name = 'Targo';
  }
  return company_name;
}