ffb95c2786618dbea2f5bb8de0ef97ba08d989fdb5eb2a0b627d31cf6f213af45087d6f19b3d2f2849b7338e545665ea14aa10a9be3ea1869337d734d8242a 602 B

123456789101112131415161718192021222324
  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. // FORMATTING
  7. addFormatToken('Q', 0, 'Qo', 'quarter');
  8. // PARSING
  9. addRegexToken('Q', match1);
  10. addParseToken('Q', function (input, array) {
  11. array[MONTH] = (toInt(input) - 1) * 3;
  12. });
  13. // MOMENTS
  14. export function getSetQuarter(input) {
  15. return input == null
  16. ? Math.ceil((this.month() + 1) / 3)
  17. : this.month((input - 1) * 3 + (this.month() % 3));
  18. }