everyutil
Version:
A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.
15 lines (14 loc) • 524 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFiscalQuarter = void 0;
/**
* Returns fiscal quarter based on date and custom fiscal year start.
* @author @dailker
* @param {Date} date
* @param {number} [fiscalYearStartMonth=0] - 0=Jan, 3=Apr, etc.
* @returns {number}
*/
function getFiscalQuarter(date, fiscalYearStartMonth = 0) {
return Math.floor(((date.getMonth() - fiscalYearStartMonth + 12) % 12) / 3) + 1;
}
exports.getFiscalQuarter = getFiscalQuarter;