// this function is used to get the date without timezone
export const getDateWithoutTimezone = (date: Date | string) =>
  new Date(new Date(date).toISOString().slice(0, -1));

// this function is used to get the date with fixed timezone
export const getISODateStringWithFixedTimezone = (date: Date | string) => {
  const _date = new Date(date);
  const userTimezoneOffset = _date.getTimezoneOffset() * 60000;
  return new Date(_date.getTime() - userTimezoneOffset)
    .toISOString()
    .slice(0, -1);
};

// This logic is copied from  wix-design-systems-locale-utils
// it should be imported from wix-design-systems-locale-utils
export const shortDateFormats = {
  en: 'MM/dd/yyyy',
  'en-US': 'MM/dd/yyyy',
  'en-GB': 'dd/MM/yyyy',
  'en-AU': 'dd/MM/yyyy',
  'en-CA': 'yyyy-MM-dd',
  ar: 'dd/MM/yyyy',
  bg: 'dd/MM/yyyy',
  ca: 'dd/MM/y',
  zh: 'MM/dd/yyyy',
  'zh-TW': 'yy-MM-dd',
  'zh-HK': 'yy-MM-dd',
  'zh-MO': 'MM/dd/yyyy',
  cs: 'dd.MM.yyyy',
  da: 'dd/MM/y',
  nl: 'dd-MM-y',
  fi: 'd.M.y',
  fr: 'dd/MM/y',
  'fr-CA': 'yy-MM-dd',
  'fr-CH': 'dd.MM.y',
  'fr-BE': 'MM/dd/yyyy',
  de: 'dd.MM.y',
  'de-CH': 'MM/dd/yyyy',
  'de-AT': 'dd.MM.y',
  el: 'd/M/yy',
  he: 'd.M.y',
  hi: 'dd/MM/yyyy',
  hu: 'y. MM. dd.',
  id: 'd/M/yyyy',
  it: 'dd/MM/y',
  ja: 'y/MM/dd',
  ko: 'y.MM.dd',
  lt: 'y-MM-dd',
  ms: 'd/M/yyyy',
  no: 'MM/dd/yyyy',
  nb: 'dd.MM.y',
  nn: 'dd.MM.y',
  pl: 'dd.MM.y',
  'pt-BR': 'dd/MM/yyyy',
  pt: 'dd/MM/y',
  ro: 'dd.MM.yyyy',
  ru: 'dd.MM.y',
  sk: 'd. M. y',
  sl: 'd. MM. yy',
  es: 'dd/MM/y',
  'es-419': 'MM/dd/yyyy',
  'es-AR': 'MM/dd/yyyy',
  'es-MX': 'MM/dd/yyyy',
  'es-US': 'MM/dd/yyyy',
  sv: 'y-MM-dd',
  tl: 'MM/dd/yyyy',
  th: 'dd/MM/yyyy',
  tr: 'dd.MM.yyyy',
  uk: 'dd.MM.y',
  vi: 'dd/MM/y',
};
