Skip to content

Commit

Permalink
Merge pull request moment#2128 from ichernev:locale-dow-doy
Browse files Browse the repository at this point in the history
Add firstDayOfWeek, firstDayOfYear locale getters
  • Loading branch information
ichernev committed Dec 28, 2014
2 parents d67554f + 4b378d1 commit 436371c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,14 @@
doy : 6 // The week that contains Jan 1st is the first week of the year.
},

firstDayOfWeek : function () {
return this._week.dow;
},

firstDayOfYear : function () {
return this._week.doy;
},

_invalidDate: 'Invalid date',
invalidDate: function () {
return this._invalidDate;
Expand Down
9 changes: 9 additions & 0 deletions test/moment/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ exports.locale = {
test.done();
},

'firstDayOfWeek firstDayOfYear locale getters' : function (test) {
moment.locale('something', {week: {dow: 3, doy: 4}});
moment.locale('something');
test.equal(moment.localeData().firstDayOfWeek(), 3, 'firstDayOfWeek');
test.equal(moment.localeData().firstDayOfYear(), 4, 'firstDayOfYear');

test.done();
},

'instance locale method' : function (test) {
moment.locale('en');

Expand Down

0 comments on commit 436371c

Please sign in to comment.