diff --git a/src/plugin/quarterOfYear/index.js b/src/plugin/quarterOfYear/index.js index 0ec48906..681d7346 100644 --- a/src/plugin/quarterOfYear/index.js +++ b/src/plugin/quarterOfYear/index.js @@ -4,7 +4,7 @@ export default (o, c) => { const proto = c.prototype proto.quarter = function (quarter) { if (!this.$utils().u(quarter)) { - return this.add((quarter - 1) * 3, M) + return this.month((this.month() % 3) + ((quarter - 1) * 3)) } return Math.ceil((this.month() + 1) / 3) } diff --git a/test/plugin/quarterOfYear.test.js b/test/plugin/quarterOfYear.test.js index 9b715253..00d1b7cc 100644 --- a/test/plugin/quarterOfYear.test.js +++ b/test/plugin/quarterOfYear.test.js @@ -31,6 +31,9 @@ it('set QuarterOfYear', () => { const d2 = '2013-02-05T05:06:07.000' expect(dayjs(d2).quarter(2).format()) .toBe(moment(d2).quarter(2).format()) + const d3 = '2018-11-25T05:06:07.000' + expect(dayjs(d3).quarter(3).format()) + .toBe(moment(d3).quarter(3).format()) }) it('add subtract quarter', () => {