|
1 | 1 | import { MS, Y, D, W } from '../../constant'
|
2 | 2 |
|
3 |
| -export default (o, c) => { |
| 3 | +export default (o, c, d) => { |
4 | 4 | const proto = c.prototype
|
5 | 5 | proto.week = function (week = null) {
|
6 | 6 | if (week !== null) {
|
7 | 7 | return this.add((week - this.week()) * 7, D)
|
8 | 8 | }
|
9 | 9 | const yearStart = this.$locale().yearStart || 1
|
10 | 10 | if (this.month() === 11 && this.date() > 25) {
|
11 |
| - const nextYearStartDay = this.startOf(Y).add(1, Y).date(yearStart) |
12 |
| - const thisEndOfWeek = this.endOf(W) |
| 11 | + // d(this) is for badMutable |
| 12 | + const nextYearStartDay = d(this).startOf(Y).add(1, Y).date(yearStart) |
| 13 | + const thisEndOfWeek = d(this).endOf(W) |
13 | 14 | if (nextYearStartDay.isBefore(thisEndOfWeek)) {
|
14 | 15 | return 1
|
15 | 16 | }
|
16 | 17 | }
|
17 |
| - const yearStartDay = this.startOf(Y).date(yearStart) |
| 18 | + const yearStartDay = d(this).startOf(Y).date(yearStart) |
18 | 19 | const yearStartWeek = yearStartDay.startOf(W).subtract(1, MS)
|
19 | 20 | const diffInWeek = this.diff(yearStartWeek, W, true)
|
20 | 21 | if (diffInWeek < 0) {
|
21 |
| - return this.startOf('week').week() |
| 22 | + return d(this).startOf('week').week() |
22 | 23 | }
|
23 | 24 | return Math.ceil(diffInWeek)
|
24 | 25 | }
|
|
0 commit comments