All files end-of-day.ts

100% Statements 8/8
100% Branches 3/3
100% Functions 1/1
100% Lines 8/8

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 19 20 21                      1x 4x 1x 1x 1x 1x   3x 3x  
import { type DateOptions } from './date.ts';
 
/**
 * Determine the end of the day for a date
 * @param input - The date
 * @param options - see {@link DateOptions}
 * @defaultValue utc false
 * @returns The date value for the last millisecond of the specified day
 * @group Time
 * @category Day
 */
export function endOfDay(input: Date, { utc = false }: DateOptions = {}): Date {
  if (utc) {
    return new Date(
      Date.UTC(input.getUTCFullYear(), input.getUTCMonth(), input.getUTCDate(), 23, 59, 59, 999),
    );
  }
 
  return new Date(input.getFullYear(), input.getMonth(), input.getDate(), 23, 59, 59, 999);
}