"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.formatDate = void 0;
var _moment = _interopRequireDefault(require("moment"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getShortDateFormat = function getShortDateFormat(value) {
  return value.replace(/Y|,$/gi, "").trim();
};
var formatDate = exports.formatDate = function formatDate(value) {
  var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "YYYY-MM-DD";
  var long = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  if (typeof value === "undefined") {
    return "";
  }
  var date;
  var year;
  if (typeof value === "number") {
    date = _moment.default.unix(value);
    year = (0, _moment.default)().utc().year();
  } else {
    date = (0, _moment.default)(value);
    year = (0, _moment.default)().year();
  }
  if (!long) {
    if (date.year() === year) {
      return date.format(getShortDateFormat(format));
    }
  }
  return date.format(format);
};
//# sourceMappingURL=dateUtils.js.map