@daysnap/utils
Version:
20 lines (12 loc) • 775 B
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _chunkBQ7SLF6Ccjs = require('./chunk-BQ7SLF6C.cjs');
var _chunkHEVW5ZN2cjs = require('./chunk-HEVW5ZN2.cjs');
// src/getDateBoundsByMonths.ts
function getDateBoundsByMonths(monthsCount = 1, date = /* @__PURE__ */ new Date(), fmt) {
const endDate = _chunkHEVW5ZN2cjs.normalizeDate.call(void 0, 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 ? [_chunkBQ7SLF6Ccjs.formatDate.call(void 0, start, fmt), _chunkBQ7SLF6Ccjs.formatDate.call(void 0, end, fmt)] : [start, end];
}
exports.getDateBoundsByMonths = getDateBoundsByMonths;