Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

Commit

Permalink
fix(weekTitle): use the correct year when the week spans 2 years
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lewis committed Mar 26, 2016
1 parent d405915 commit 638c741
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/services/calendarTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ angular
}

function week(viewDate) {
var weekTitleLabel = calendarConfig.titleFormats.week;
return weekTitleLabel.replace('{week}', moment(viewDate).isoWeek()).replace('{year}', moment(viewDate).format('YYYY'));
return calendarConfig.titleFormats.week
.replace('{week}', moment(viewDate).isoWeek())
.replace('{year}', moment(viewDate).startOf('week').format('YYYY'));
}

function month(viewDate) {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/services/calendarTitle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ describe('calendarTitle', function() {
expect(calendarTitle.week(calendarDay)).to.equal('Week 18 of 2015');
});

it('should use the start of the week for the year number', function() {
expect(calendarTitle.week(new Date('2016-01-01'))).to.equal('Week 53 of 2015');
});

it('should give the correct month title', function() {
expect(calendarTitle.month(calendarDay)).to.equal('May 2015');
});
Expand Down

0 comments on commit 638c741

Please sign in to comment.