const getMillisecond = day => 1000 * 60 * 60 * 24 * day;

export const digit = value => {
  return `${value}`.length === 1 ? `0${value}` : value;
};
export const format = dateStr => {
  if (dateStr.indexOf('-') > -1) {
    return dateStr.replace(/-/g, '/');
  }

  return dateStr;
};
export default ((day, showName) => {
  const date = new Date();
  date.setTime(date.getTime() + getMillisecond(day));
  const tYear = date.getFullYear();
  const tDate = digit(date.getDate());
  const tMonth = digit(date.getMonth() + 1);
  return {
    showName,
    date: [tYear, tMonth, tDate].join('-'),
    showDate: [tMonth, tDate].join('-')
  };
});