/** Format a Date as YYYY-MM-DD in local timezone (avoids UTC shift from toISOString). */
export function formatLocalDate(date: Date): string {
  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}`;
}

export function getYearToDateRange(): { from_date: string; to_date: string } {
  const today = new Date();
  const yearStart = new Date(today.getFullYear(), 0, 1);
  return {
    from_date: formatLocalDate(yearStart),
    to_date: formatLocalDate(today),
  };
}
