]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
making startOf('week') use locale week start #727 #634 #699
authorTim Wood <washwithcare@gmail.com>
Sat, 11 May 2013 20:00:01 +0000 (10:00 -1000)
committerTim Wood <washwithcare@gmail.com>
Sat, 11 May 2013 20:00:01 +0000 (10:00 -1000)
moment.js
test/moment/lang.js
test/moment/sod_eod.js

index 267aba5ae6c66bf549b40f9ae2e71317260c3676..0bb255cf51581a7da8ab38044e4c65119ac59ba1 100644 (file)
--- a/moment.js
+++ b/moment.js
 
             // weeks are a special case
             if (units === 'week') {
-                this.day(0);
+                this.weekday(0);
             }
 
             return this;
index bece6bfca1e77cf265543555678f0d628bae7c37..18e6e0bb8df962b2949dd6b404df07a08103199f 100644 (file)
@@ -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();
     }
 };
index 21ddc442ec074c24ccbc54707a9198557d010a4d..98338b968883d33d708a75989f64cf9c60727d6c 100644 (file)
@@ -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);