export function getRunDays(date) {
  const launchDate = new Date(date)
  const today = new Date() // 替换为当前日期

  const timeDiff = today - launchDate // 毫秒差
  const daysRun = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)) // 转换为天数

  return daysRun
}
export function processData(data, keys) {
  // data.sort((a, b) => {
  //   return new Date(a.dt) - new Date(b.dt)
  // })
  const dates = data.map((item) => item.dt)
  const values = []
  keys.forEach((item, index) => {
    values[index] = data.map((dataValue) => dataValue[keys[index]])
  })

  return {
    dates,
    values
  }
}

export function getDateDaysAgo(daysAgo) {
  const date = new Date()
  date.setDate(date.getDate() - daysAgo)

  const year = date.getFullYear()
  const month = String(date.getMonth() + 1).padStart(2, '0')
  const day = String(date.getDate()).padStart(2, '0')

  return `${year}-${month}-${day}`
}
