PageRenderTime 31ms CodeModel.GetById 22ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/moment/src/lib/units/day-of-year.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 36 lines | 20 code | 10 blank | 6 comment | 1 complexity | 9a1909e4a60fedc123920cafbfc0e90f MD5 | raw file
 1import { addFormatToken } from '../format/format';
 2import { addUnitAlias } from './aliases';
 3import { addUnitPriority } from './priorities';
 4import { addRegexToken, match3, match1to3 } from '../parse/regex';
 5import { daysInYear } from './year';
 6import { createUTCDate } from '../create/date-from-array';
 7import { addParseToken } from '../parse/token';
 8import toInt from '../utils/to-int';
 9
10// FORMATTING
11
12addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
13
14// ALIASES
15
16addUnitAlias('dayOfYear', 'DDD');
17
18// PRIORITY
19addUnitPriority('dayOfYear', 4);
20
21// PARSING
22
23addRegexToken('DDD',  match1to3);
24addRegexToken('DDDD', match3);
25addParseToken(['DDD', 'DDDD'], function (input, array, config) {
26    config._dayOfYear = toInt(input);
27});
28
29// HELPERS
30
31// MOMENTS
32
33export function getSetDayOfYear (input) {
34    var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
35    return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
36}