PageRenderTime 17ms CodeModel.GetById 8ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/coleman333/smartsite
JavaScript | 39 lines | 23 code | 10 blank | 6 comment | 1 complexity | 01ff4893a3d3ffea4838b5e399d4a52f MD5 | raw file
 1import { makeGetSet } from '../moment/get-set';
 2import { addFormatToken } from '../format/format';
 3import { addUnitAlias } from './aliases';
 4import { addUnitPriority } from './priorities';
 5import { addRegexToken, match1to2, match2 } from '../parse/regex';
 6import { addParseToken } from '../parse/token';
 7import { DATE } from './constants';
 8import toInt from '../utils/to-int';
 9
10// FORMATTING
11
12addFormatToken('D', ['DD', 2], 'Do', 'date');
13
14// ALIASES
15
16addUnitAlias('date', 'D');
17
18// PRIOROITY
19addUnitPriority('date', 9);
20
21// PARSING
22
23addRegexToken('D',  match1to2);
24addRegexToken('DD', match1to2, match2);
25addRegexToken('Do', function (isStrict, locale) {
26    // TODO: Remove "ordinalParse" fallback in next major release.
27    return isStrict ?
28      (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
29      locale._dayOfMonthOrdinalParseLenient;
30});
31
32addParseToken(['D', 'DD'], DATE);
33addParseToken('Do', function (input, array) {
34    array[DATE] = toInt(input.match(match1to2)[0]);
35});
36
37// MOMENTS
38
39export var getSetDayOfMonth = makeGetSet('Date', true);