// 时间格式化
function formatTime(date, month_str, minute_str, status) {

  if (!date) {
    return 0
  }
  date = date.replace(getRegExp('-', 'g'), '/');

  var _date = getDate(date);
 
  var year = _date.getFullYear();
  var month = _date.getMonth() + 1;
  var day = _date.getDate();
  var hour = _date.getHours();
  var minute = _date.getMinutes();
  var second = _date.getSeconds();

  if (status) {
    return [year, month, day].map(formatNumber).join(month_str || '/')
  }
  return [year, month, day].map(formatNumber).join(month_str || '/') + ' ' + [hour, minute].map(formatNumber).join(minute_str || ':');
}

function formatNumber(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
}

function getTimeStatus(exchangeStartDate, exchangeEndDate) {
  var start = '1900-01-01';
  var end = '2100-01-01';
  var _start = exchangeStartDate.split(' ')[0];
  var _end = exchangeEndDate.split(' ')[0];
  if (start === _start && end === _end) {
    return '不限'
  } else {

    return formatTime(exchangeStartDate, '.', '', true) + ' - ' + formatTime(exchangeEndDate, '.', '', true)
  }
}

module.exports = {
  getTimeStatus: getTimeStatus,
  formatTime: formatTime
};