Skip to content

Commit

Permalink
chore: Update weekOfYear
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Mar 10, 2019
1 parent c466632 commit 1ddf633
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugin/weekOfYear/index.js
Expand Up @@ -6,11 +6,12 @@ export default (o, c, d) => {
if (week !== null) {
return this.add((week - this.week()) * 7, 'day')
}
const endOfYear = this.endOf(Y)
// d(this) clone is for badMutable plugin
const endOfYear = d(this).endOf(Y)
if (endOfYear.day() !== 6 && this.month() === 11 && (31 - this.date()) <= endOfYear.day()) {
return 1
}
const startOfYear = d(this.$d).startOf(Y)
const startOfYear = d(this).startOf(Y)
const compareDay = startOfYear.subtract(startOfYear.day(), D).subtract(1, MS)
const diffInWeek = this.diff(compareDay, W, true)
return Math.ceil(diffInWeek)
Expand Down

0 comments on commit 1ddf633

Please sign in to comment.