1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match3, match1to3 } from '../parse/regex';
4 import { daysInYear } from './year';
5 import { createUTCDate } from '../create/date-from-array';
6 import { addParseToken } from '../parse/token';
7 import toInt from '../utils/to-int';
11 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
15 addUnitAlias('dayOfYear', 'DDD');
19 addRegexToken('DDD', match1to3);
20 addRegexToken('DDDD', match3);
21 addParseToken(['DDD', 'DDDD'], function (input, array, config) {
22 config._dayOfYear = toInt(input);
29 export function getSetDayOfYear (input) {
30 var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
31 return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');