UNPKG

@technobuddha/library

Version:
33 lines (32 loc) 1.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDaysInMonth = void 0; var constants_1 = require("../constants"); var isLeapYear_1 = __importDefault(require("../isLeapYear")); /** * Determine the number of days in the month for a date * * @param input The date * @param __namedParameters see {@link Options} * @default UTC false * @returns The number of days in the specified month */ function getDaysInMonth(input, _a) { var _b = _a === void 0 ? {} : _a, _c = _b.UTC, UTC = _c === void 0 ? false : _c; switch (UTC ? input.getUTCMonth() : input.getMonth()) { case constants_1.month.april: case constants_1.month.june: case constants_1.month.september: case constants_1.month.november: return 30; case constants_1.month.february: return isLeapYear_1.default(input) ? 29 : 28; default: return 31; } } exports.getDaysInMonth = getDaysInMonth; exports.default = getDaysInMonth;