// src/utils/dateUtils.ts

/**
 * Calculates the current year and a simplified week number.
 *
 * Note: This is a simple calculation where week 1 starts on January 1st.
 * For true ISO 8601 week numbers (where week 1 is the first week with a Thursday),
 * a dedicated library like `date-fns` (`getISOWeek` and `getISOWeekYear`) is recommended.
 *
 * @param date The date to calculate the week for. Defaults to the current date.
 * @returns An object containing the year and week number.
 */
export function getSimpleWeekAndYear(date: Date = new Date()): { year: number; week: number } {
    const year = date.getFullYear();
    const startOfYear = new Date(year, 0, 1);
    // Calculate the difference in days from the start of the year (day 0 to 364/365)
    const dayOfYear = (date.getTime() - startOfYear.getTime()) / (1000 * 60 * 60 * 24);
    // Divide by 7, take the floor to get the zero-based week, and add 1 for a one-based week number.
    const week = Math.floor(dayOfYear / 7) + 1;

    return { year, week };
}