UNPKG

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.

17 lines (16 loc) 552 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDaysInQuarter = void 0; /** * Returns total days in the quarter for a given date. * @author @dailker * @param {Date} date * @returns {number} */ function getDaysInQuarter(date) { const q = Math.floor(date.getMonth() / 3); const year = date.getFullYear(); const months = [q * 3, q * 3 + 1, q * 3 + 2]; return months.reduce((sum, m) => sum + new Date(year, m + 1, 0).getDate(), 0); } exports.getDaysInQuarter = getDaysInQuarter;