• Not Exported

    Gets the start and end dates of the week containing the given date

    Parameters

    • date: Date

    Returns { startDate: Date; endDate: Date }

    function getWeekStartAndEndDates(date: Date): {
    startDate: Date;
    endDate: Date;
    } {
    const d = new Date(date.getTime());
    d.setHours(0, 0, 0, 0);

    // Find Sunday of this week (first day)
    const dayOfWeek = d.getDay();
    const startDate = new Date(d.getTime());
    startDate.setDate(d.getDate() - dayOfWeek);

    // Find Saturday of this week (last day)
    const endDate = new Date(startDate.getTime());
    endDate.setDate(startDate.getDate() + 6);

    return { startDate, endDate };
    }