All files end-of-year.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191x                       1x 2x 1x 1x 1x 1x  
import { month } from './date.ts';
import { type DateOptions } from './date.ts';
 
/**
 * Determine the last day of the year containing a date
 * @param input - The date
 * @param options - see {@link DateOptions}
 * @defaultValue utc false
 * @returns Midnight of the last day of the year containing the input date
 * @group Time
 * @category Year
 */
export function endOfYear(input: Date, { utc = false }: DateOptions = {}): Date {
  if (utc) {
    return new Date(Date.UTC(input.getUTCFullYear(), month.december, 31));
  }
  return new Date(input.getFullYear(), month.december, 31);
}