Skip to content

Commit 434f774

Browse files
authored
fix: Fix QuarterOfYear plugin bug (#591)
1 parent de14682 commit 434f774

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/plugin/quarterOfYear/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default (o, c) => {
44
const proto = c.prototype
55
proto.quarter = function (quarter) {
66
if (!this.$utils().u(quarter)) {
7-
return this.add((quarter - 1) * 3, M)
7+
return this.month((this.month() % 3) + ((quarter - 1) * 3))
88
}
99
return Math.ceil((this.month() + 1) / 3)
1010
}

test/plugin/quarterOfYear.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ it('set QuarterOfYear', () => {
3131
const d2 = '2013-02-05T05:06:07.000'
3232
expect(dayjs(d2).quarter(2).format())
3333
.toBe(moment(d2).quarter(2).format())
34+
const d3 = '2018-11-25T05:06:07.000'
35+
expect(dayjs(d3).quarter(3).format())
36+
.toBe(moment(d3).quarter(3).format())
3437
})
3538

3639
it('add subtract quarter', () => {

0 commit comments

Comments
 (0)