@technobuddha/library
Version:
A large library of useful functions
16 lines (15 loc) • 611 B
JavaScript
import getDaysInMonth from '../getDaysInMonth';
/**
* Determine the last day of the month containing the input date
*
* @param input The date
* @param __namedParameters see {@link Options}
* @default UTC false
* @returns Midnight on the last day of the month corresponding to the input date
*/
export function getEndOfMonth(input, { UTC = false } = {}) {
if (UTC)
return new Date(Date.UTC(input.getUTCFullYear(), input.getUTCMonth(), getDaysInMonth(input, { UTC })));
return new Date(input.getFullYear(), input.getMonth(), getDaysInMonth(input, { UTC }));
}
export default getEndOfMonth;