@technobuddha/library
Version:
A large library of useful functions
16 lines (15 loc) • 522 B
JavaScript
import { month } from '../constants';
/**
* Determine the start of the year for a date
*
* @param input The date
* @param __namedParameters see {@link Options}
* @default UTC false
* @returns The date value for midnight on the first day of the specified year
*/
export function getBeginningOfYear(input, { UTC = false } = {}) {
if (UTC)
return new Date(Date.UTC(input.getUTCFullYear(), month.january, 1));
return new Date(input.getFullYear(), month.january, 1);
}
export default getBeginningOfYear;