UNPKG

@daysnap/utils

Version:
20 lines (17 loc) 577 B
import { formatDate } from "./chunk-UMJU7UF2.js"; import { normalizeDate } from "./chunk-A3YS6665.js"; // src/getDateBoundsByMonths.ts function getDateBoundsByMonths(monthsCount = 1, date = /* @__PURE__ */ new Date(), fmt) { const endDate = normalizeDate(date); const end = new Date(endDate.getFullYear(), endDate.getMonth() + 1, 0); const startMonth = end.getMonth() - (monthsCount - 1); const start = new Date(end.getFullYear(), startMonth, 1); return fmt ? [formatDate(start, fmt), formatDate(end, fmt)] : [start, end]; } export { getDateBoundsByMonths };