/** Generate an array of date strings (YYYY-MM-DD) for the last N days. */
export function useDates() {
  function formatDate(d: Date): string {
    const y = d.getFullYear()
    const m = String(d.getMonth() + 1).padStart(2, "0")
    const day = String(d.getDate()).padStart(2, "0")
    return `${y}-${m}-${day}`
  }

  function getToday(): string {
    return formatDate(new Date())
  }

  function lastDays(count: number): string[] {
    return Array.from({ length: count }, (_, i) => {
      const d = new Date()
      d.setDate(d.getDate() - i)
      return formatDate(d)
    })
  }

  return { formatDate, getToday, lastDays }
}
