@technobuddha/library
Version:
A large library of useful functions
14 lines (10 loc) • 431 B
text/typescript
import { ticksPerDay } from '../constants';
import floor from '../floor';
import getBeginningOfYear from '../getBeginningOfYear';
type Options = {
UTC?: boolean;
};
export function getDayOfYear(input: Date, { UTC = false }: Options = {}): number {
return floor((input.getTime() - getBeginningOfYear(input, { UTC }).getTime()) / ticksPerDay, { tolerance: 0.05 }) + 1;
}
export default getDayOfYear;