Debian Codegraph @

vendor/static/moment/src/lib/units/quarter.js

raw
1 import { addFormatToken } from '../format/format';
2 import { addRegexToken, match1 } from '../parse/regex';
3 import { addParseToken } from '../parse/token';
4 import { MONTH } from './constants';
5 import toInt from '../utils/to-int';
6
7 // FORMATTING
8
9 addFormatToken('Q', 0, 'Qo', 'quarter');
10
11 // PARSING
12
13 addRegexToken('Q', match1);
14 addParseToken('Q', function (input, array) {
15 array[MONTH] = (toInt(input) - 1) * 3;
16 });
17
18 // MOMENTS
19
20 export function getSetQuarter(input) {
21 return input == null
22 ? Math.ceil((this.month() + 1) / 3)
23 : this.month((input - 1) * 3 + (this.month() % 3));
24 }