import moment from 'moment';

export const switchTimeToPeriod = (time) => {
  if (!time) return '';
  let _day = 0;
  let _hour = 0;
  let _minutes = 0;
  _day = moment().diff(moment(time), 'days');
  _hour = moment().diff(moment(time), 'hours');
  _minutes = moment().diff(moment(time), 'minutes');

  return (
    `${_day ? _day + '天' : ''}${_hour ? _hour - _day * 24 + '小时' : ''}${
      _minutes ? _minutes - _hour * 60 + '分钟' : ''
    }` || '刚刚'
  );
};
