From: Tim Wood Date: Sat, 11 May 2013 20:00:01 +0000 (-1000) Subject: making startOf('week') use locale week start #727 #634 #699 X-Git-Tag: 2.1.0~32^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a58e5b7c5d71c99d6ae44cc1cb30072d47c6c2ae;p=thirdparty%2Fmoment.git making startOf('week') use locale week start #727 #634 #699 --- diff --git a/moment.js b/moment.js index 267aba5ae..0bb255cf5 100644 --- a/moment.js +++ b/moment.js @@ -1334,7 +1334,7 @@ // weeks are a special case if (units === 'week') { - this.day(0); + this.weekday(0); } return this; diff --git a/test/moment/lang.js b/test/moment/lang.js index bece6bfca..18e6e0bb8 100644 --- a/test/moment/lang.js +++ b/test/moment/lang.js @@ -195,6 +195,22 @@ exports.lang = { test.equal(moment([2011, 0, 1]).format('MMMM MMM'), 'a A', 'should be able to set language values after creating the language'); + test.done(); + }, + + "start/endOf week feature for first-day-is-monday langs" : function (test) { + test.expect(2); + + moment.lang('monday-lang', { + week : { + dow : 1 // Monday is the first day of the week + } + }); + + moment.lang('monday-lang'); + test.equal(moment([2013, 0, 1]).startOf('week').day(), 1, 'for lang monday-lang first day of the week should be monday'); + test.equal(moment([2013, 0, 1]).endOf('week').day(), 0, 'for lang monday-lang last day of the week should be sunday'); + test.done(); } }; diff --git a/test/moment/sod_eod.js b/test/moment/sod_eod.js index 21ddc442e..98338b968 100644 --- a/test/moment/sod_eod.js +++ b/test/moment/sod_eod.js @@ -1,6 +1,16 @@ var moment = require("../../moment"); exports.end_start_of = { + setUp : function (cb) { + moment.lang('en'); + cb(); + }, + + tearDown : function (cb) { + moment.lang('en'); + cb(); + }, + "start of year" : function(test) { test.expect(9);