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.

22 lines (21 loc) 595 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.countWeekdaysBetween = void 0; /** * Counts how many weekdays fall between two dates (inclusive). * @author @dailker * @param {Date} start * @param {Date} end * @returns {number} */ function countWeekdaysBetween(start, end) { let count = 0; let d = new Date(start); while (d <= end) { if (d.getDay() !== 0 && d.getDay() !== 6) count++; d.setDate(d.getDate() + 1); } return count; } exports.countWeekdaysBetween = countWeekdaysBetween;