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 | 1x 1x 1x 1x 9x 9x 9x 9x 9x | import { beginningOfYear } from './beginning-of-year.ts'; import { type DateOptions, ticksPerDay } from './date.ts'; import { floor } from './floor.ts'; /** * Calculates the day of the year for a given date. * @param input - The date for which to calculate the day of the year. * @param options - Optional settings. * @returns The day of the year as a number (1-based). * @group Time * @category Year */ export function dayOfYear(input: Date, { utc = false }: DateOptions = {}): number { return ( floor((input.getTime() - beginningOfYear(input, { utc }).getTime()) / ticksPerDay, { tolerance: 0.05, }) + 1 ); } |