const pad = (value) => String(value).padStart(2, '0'); export function formatDateInput(date) { return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`; } export function lastSevenDays(reference = new Date()) { const end = new Date(reference.getFullYear(), reference.getMonth(), reference.getDate()); const start = new Date(end); start.setDate(start.getDate() - 6); return { startDate: formatDateInput(start), endDate: formatDateInput(end) }; } export function dateRangeParams(startDate, endDate, fromKey = 'startedFrom', toKey = 'startedTo') { const params = {}; if (startDate) params[fromKey] = new Date(`${startDate}T00:00:00`).toISOString(); if (endDate) params[toKey] = new Date(`${endDate}T23:59:59.999`).toISOString(); return params; }