'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactHtmlParser = require('react-html-parser');

var _reactHtmlParser2 = _interopRequireDefault(_reactHtmlParser);

require('./style.css');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var timeFormat = new Intl.DateTimeFormat('en-US', {
  hour12: true,
  hour: 'numeric',
  minute: 'numeric'
});
var dateFormat = new Intl.DateTimeFormat('en-US', {
  weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'
});

var EventTime = function EventTime(props) {
  var startDate = props.startDate,
      endDate = props.endDate,
      details = props.details;

  return _react2.default.createElement(
    'span',
    { className: 'ma__event-time' },
    _react2.default.createElement(
      'div',
      { className: 'ma__event-time__calendar' },
      _react2.default.createElement(
        'div',
        { className: 'ma__event-time__date' },
        dateFormat.format(startDate)
      ),
      _react2.default.createElement(
        'div',
        { className: 'ma__event-time__time' },
        timeFormat.format(startDate) + ' - ' + timeFormat.format(endDate)
      )
    ),
    details && _react2.default.createElement(
      'p',
      { className: 'ma__contact__details' },
      (0, _reactHtmlParser2.default)(details)
    )
  );
};

EventTime.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The start date of the event. */
  startDate: _propTypes2.default.instanceOf(Date).isRequired,
  /** The end date of the event. */
  endDate: _propTypes2.default.instanceOf(Date).isRequired,
  /** Details around the event. */
  details: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object])
} : {};

exports.default = EventTime;
module.exports = exports['default'];