const monthsAgo = (months: number) => {
  const { subMonths, startOfMonth, format } = require("date-fns");

  // Get the current date
  const currentDate = new Date();

  // Subtract 4 months from the current date
  const monthsAgo = subMonths(currentDate, months);

  // Get the start of the month for the current date and four months ago
  // const startOfCurrentMonth = startOfMonth(currentDate);
  const startMonthsAgo = startOfMonth(monthsAgo);

  // Format the dates in YYYY-MM-DD format
  // const formattedCurrentMonth = format(startOfCurrentMonth, "yyyy-MM-dd");
  const formattedMonthsAgo = format(startMonthsAgo, "yyyy-MM-dd");

  // console.log("Current Month:", formattedCurrentMonth);
  // console.log("Months Ago:", formattedMonthsAgo);
  return formattedMonthsAgo;
};

export default monthsAgo;
