"use strict";

exports.__esModule = true;
exports.zonedDate = zonedDate;
exports.format = exports.toLocalTimeZone = exports.toTimeZone = void 0;

var _dateFnsTz = require("date-fns-tz");

var _dateUtils = require("./dateUtils");

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

  return (0, _dateFnsTz.utcToZonedTime)(date, timeZone);
};

exports.toTimeZone = toTimeZone;

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

  return (0, _dateFnsTz.zonedTimeToUtc)(date, timeZone);
};

exports.toLocalTimeZone = toLocalTimeZone;

var format = function format(date, formatStr, timeZone) {
  if (timeZone) {
    return (0, _dateFnsTz.format)(date, formatStr, {
      timeZone: timeZone
    });
  }

  return (0, _dateUtils.format)(date, formatStr);
};

exports.format = format;

function zonedDate(timeZone) {
  return toTimeZone(new Date(), timeZone);
}