UNPKG

@technobuddha/library

Version:
25 lines (24 loc) 705 B
import { month } from '../constants'; import isLeapYear from '../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 */ export function getDaysInMonth(input, { UTC = false } = {}) { switch (UTC ? input.getUTCMonth() : input.getMonth()) { case month.april: case month.june: case month.september: case month.november: return 30; case month.february: return isLeapYear(input) ? 29 : 28; default: return 31; } } export default getDaysInMonth;