text: "use strict";
  
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = dateParser;
  
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
  
  var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/parse-int"));
  
  var _toArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toArray"));
  
  var _isNan = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/number/is-nan"));
  
  function dateParser(date) {
    var parsed = new Date(date);
  
    if (!(0, _isNan.default)(parsed.valueOf())) {
      return parsed;
    }
  
    var parts = String(date).match(/\d+/g);
  
    if (parts == null || parts.length <= 2) {
      return parsed;
    } else {
      var _parts$map = parts.map(function (x) {
        return (0, _parseInt2.default)(x);
      }),
          _parts$map2 = (0, _toArray2.default)(_parts$map),
          firstP = _parts$map2[0],
          secondP = _parts$map2[1],
          restPs = _parts$map2.slice(2);
  
      var correctedParts = [firstP, secondP - 1].concat((0, _toConsumableArray2.default)(restPs));
      var isoDate = new Date(Date.UTC.apply(Date, (0, _toConsumableArray2.default)(correctedParts)));
      return isoDate;
    }
  }