Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix(weekTitle): use the correct year when the week spans 2 years

  • Loading branch information...
Matt Lewis
Matt Lewis committed Mar 26, 2016
1 parent d405915 commit 638c74178db5f4ec6ef9dbf3ac3e5680a7838c13
Showing with 7 additions and 2 deletions.
  1. +3 −2 src/services/calendarTitle.js
  2. +4 −0 test/unit/services/calendarTitle.spec.js
@@ -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) {
@@ -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');
});

0 comments on commit 638c741

Please sign in to comment.
You can’t perform that action at this time.