UNPKG

@daysnap/utils

Version:
22 lines (19 loc) 556 B
import { formatDate } from "./chunk-UMJU7UF2.js"; import { normalizeDate } from "./chunk-A3YS6665.js"; // src/getWeekBounds.ts function getWeekBounds(value, sundayIsFirstDay = true, fmt) { const start = normalizeDate(value); const end = new Date(start); const day = start.getDay(); const diffDay = sundayIsFirstDay ? day * -1 : day === 0 ? -6 : 1 - day; start.setDate(start.getDate() + diffDay); end.setDate(start.getDate() + 6); return fmt ? [formatDate(start, fmt), formatDate(end, fmt)] : [start, end]; } export { getWeekBounds };