Skip to content

Commit

Permalink
bugfix: weekyear setter handle dow
Browse files Browse the repository at this point in the history
Fixes #3944
  • Loading branch information
ichernev committed Dec 23, 2023
1 parent 5718d97 commit 6767277
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/units/week-year.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function getSetWeekYear(input) {
this,
input,
this.week(),
this.weekday(),
this.weekday() + this.localeData()._week.dow,
this.localeData()._week.dow,
this.localeData()._week.doy
);
Expand Down
8 changes: 8 additions & 0 deletions src/test/moment/week_year.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ test('week year', function (assert) {
assert.equal(moment([2008, 11, 29]).weekYear(), 2009);
assert.equal(moment([2009, 11, 27]).weekYear(), 2009);
assert.equal(moment([2009, 11, 28]).weekYear(), 2010);

moment.locale('dow:1 doy:4', { week: { dow: 1, doy: 4 } });
assert.equal(moment([2015, 11, 27]).locale('dow:1 doy:4').weekYear(), 2015);
assert.equal(
moment([2015, 11, 27]).locale('dow:1 doy:4').weekYear(2015).date(),
27
);
moment.defineLocale('dow:1 doy:4', null);
});

// Verifies that the week number, week day computation is correct for all dow, doy combinations
Expand Down

0 comments on commit 6767277

Please sign in to comment.