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.

20 lines (19 loc) 544 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNextLeapDay = void 0; /** * Gets the next Feb 29 after a given date. * @author @dailker * @param {Date} date * @returns {Date} */ function getNextLeapDay(date) { let year = date.getFullYear(); let d = new Date(year, 1, 29); if (d <= date) year++; while (!(year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0))) year++; return new Date(year, 1, 29); } exports.getNextLeapDay = getNextLeapDay;