export function generateRandomDateTimeByYear(year) {
  // 生成随机月份(1-12)
  const month = Math.floor(Math.random() * 12) + 1;

  // 生成随机日期(1-31)
  const day = Math.floor(Math.random() * 31) + 1;

  // 生成随机小时(0-23)
  const hour = Math.floor(Math.random() * 24);

  // 生成随机分钟(0-59)
  const minute = Math.floor(Math.random() * 60);

  // 生成随机秒钟(0-59)
  const second = Math.floor(Math.random() * 60);

  // 返回随机日期和时间的字符串
  return `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day} ${
    hour < 10 ? '0' : ''
  }${hour}:${minute < 10 ? '0' : ''}${minute}:${second < 10 ? '0' : ''}${second}`;
}

export function generateRandomMoment(date = new Date(), type = 'HH:mm:ss') {
  // 生成随机小时(0-23)
  const hour = Math.floor(Math.random() * 24);

  // 生成随机分钟(0-59)
  const minute = Math.floor(Math.random() * 60);

  // 生成随机秒钟(0-59)
  const second = Math.floor(Math.random() * 60);
  // 返回随机日期和时间的字符串
  return `${hour < 10 ? '0' : ''}${hour}:${minute < 10 ? '0' : ''}${minute}:${
    second < 10 ? '0' : ''
  }${second}`;
}