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.

19 lines (18 loc) 588 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.endOfWeek = void 0; const startOfWeek_1 = require("./startOfWeek"); /** * Gets the end of the week for a date. * @param {Date} date * @param {number} [firstDay=1] - 0=Sunday, 1=Monday * @returns {Date} */ function endOfWeek(date, firstDay = 1) { const start = (0, startOfWeek_1.startOfWeek)(date, firstDay); const result = new Date(start); result.setDate(result.getDate() + 6); result.setHours(23, 59, 59, 999); return result; } exports.endOfWeek = endOfWeek;