bf1e114f0100296fc06e91093d749a6cbeb77ac07f5994690aa91b6049209143079c67b4210a381e9043f1db2df5ecb0c8ad88668fc73c8fa0716254ff7a1c 763 B

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