import { zonedTimeToUtc, utcToZonedTime, format as dateFnsTzFormat } from 'date-fns-tz';
import { format as dateFnsFormat } from './dateUtils';
export var toTimeZone = function toTimeZone(date, timeZone) {
  if (!(date instanceof Date) || !timeZone) {
    return date;
  }

  return utcToZonedTime(date, timeZone);
};
export var toLocalTimeZone = function toLocalTimeZone(date, timeZone) {
  if (!(date instanceof Date) || !timeZone) {
    return date;
  }

  return zonedTimeToUtc(date, timeZone);
};
export var format = function format(date, formatStr, timeZone) {
  if (timeZone) {
    return dateFnsTzFormat(date, formatStr, {
      timeZone: timeZone
    });
  }

  return dateFnsFormat(date, formatStr);
};
export function zonedDate(timeZone) {
  return toTimeZone(new Date(), timeZone);
}