"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isoToDate = void 0;
var isoToDate = value => {
  if (value === undefined || value === '') {
    return value;
  }
  var getDateFromEu = s => {
    var parts = s.split('/');
    var year = parseInt(parts[2]);
    var month = parseInt(parts[1]) - 1;
    var day = parseInt(parts[0]);
    return [day, month, year];
  };
  var getDateFromIso = s => {
    var parts = s.split('-');
    var year = parseInt(parts[0]);
    var month = parseInt(parts[1]) - 1;
    var day = parseInt(parts[2]);
    return [day, month, year];
  };

  // date
  var day, month, year;
  if (value.indexOf('/') >= 0) {
    [day, month, year] = getDateFromEu(value);
  } else {
    [day, month, year] = getDateFromIso(value);
  }

  // time
  var hour = 0,
    min = 0,
    secs = 0;
  if (value.indexOf('T') >= 0) {
    var parts = value.split('T')[1];
    parts = parts.split(':');
    hour = parseInt(parts[0]);
    min = parseInt(parts[1]);
    secs = parseInt(parts[2]);
  }
  var date = new Date(Date.UTC(year, month, day, hour, min, secs));
  return date;
};
exports.isoToDate = isoToDate;