]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
deprecating eod and sod
authorTim Wood <washwithcare@gmail.com>
Thu, 10 Jan 2013 19:19:50 +0000 (11:19 -0800)
committerTim Wood <washwithcare@gmail.com>
Thu, 10 Jan 2013 19:19:50 +0000 (11:19 -0800)
moment.js
test/moment/lang.js
test/moment/mutable.js
test/moment/sod_eod.js

index 1d9cbcf842c92e17267f8c4085b551691c0810b1..001ed56b0cf8b69015bcdf05db150ecf757c0620 100644 (file)
--- a/moment.js
+++ b/moment.js
         },
 
         calendar : function () {
-            var diff = this.diff(moment().sod(), 'days', true),
+            var diff = this.diff(moment().startOf('day'), 'days', true),
                 format = diff < -6 ? 'sameElse' :
                 diff < -1 ? 'lastWeek' :
                 diff < 0 ? 'lastDay' :
             return +this.clone().startOf(units) === +moment(input).startOf(units);
         },
 
-        sod: function () {
-            return this.clone().startOf('day');
-        },
-
-        eod: function () {
-            // end of day = start of day plus 1 day, minus 1 millisecond
-            return this.clone().endOf('day');
-        },
-
         zone : function () {
             return this._isUTC ? 0 : this._d.getTimezoneOffset();
         },
index a5d7328fd86e4c140f7f55da2b3682957c80a73a..3799a7e6ed58f0c913bd1c90a82a4f65c56aadc5 100644 (file)
@@ -98,7 +98,7 @@ exports.lang = {
 
         test.equal(moment([2012, 5, 6]).lang('es').add({days: 1}).format('MMMM'), 'junio', 'With addition');
         test.equal(moment([2012, 5, 6]).lang('es').day(0).format('MMMM'), 'junio', 'With day getter');
-        test.equal(moment([2012, 5, 6]).lang('es').eod().format('MMMM'), 'junio', 'With eod');
+        test.equal(moment([2012, 5, 6]).lang('es').endOf('day').format('MMMM'), 'junio', 'With endOf');
 
         test.done();
     },
index 4d45c94b187657590be381b98372c5813b3430ed..182700ea0458e389be04541695f97048a7bf47b0 100644 (file)
@@ -2,7 +2,7 @@ var moment = require("../../moment");
 
 exports.mutable = {
     "manipulation methods" : function (test) {
-        
+
         var mutableMethods = {
             'year':          function (m){ return m.year(2011); },
             'month':         function (m){ return m.month(1); },
@@ -34,13 +34,12 @@ exports.mutable = {
     },
 
     "non mutable methods" : function (test) {
-        
+
         var nonMutableMethods = {
-            'sod':       function (m){ return m.sod() },
-            'eod':       function (m){ return m.eod() }
+            'clone':       function (m){ return m.clone() }
         };
 
-        test.expect(2);
+        test.expect(1);
 
         for (method in nonMutableMethods){
             if (nonMutableMethods.hasOwnProperty(method)) {
index fd3a856889e423096a2b4a3b8cddaa6cfca635f9..b1420f03f4843e248e8d46fc78d670f4c77f2682 100644 (file)
@@ -1,43 +1,6 @@
 var moment = require("../../moment");
 
-exports.eod_sod = {
-    "sod" : function(test) {
-        test.expect(7);
-
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).sod();
-        test.equal(m.year(), 2011, "keep the year");
-        test.equal(m.month(), 1, "keep the month");
-        test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 0, "strip out the hours"); 
-        test.equal(m.minutes(), 0, "strip out the minutes"); 
-        test.equal(m.seconds(), 0, "strip out the seconds"); 
-        test.equal(m.milliseconds(), 0, "strip out the milliseconds");
-        test.done();
-    },
-
-    "eod" : function(test) {
-        test.expect(7);
-
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).eod();
-        test.equal(m.year(), 2011, "keep the year");
-        test.equal(m.month(), 1, "keep the month");
-        test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 23, "set the hours"); 
-        test.equal(m.minutes(), 59, "set the minutes"); 
-        test.equal(m.seconds(), 59, "set the seconds"); 
-        test.equal(m.milliseconds(), 999, "set the seconds");
-        test.done();
-    },
-
-    "eod utc" : function(test) {
-        test.expect(1);
-
-        var m2 = moment.utc(new Date(2011, 1, 2, 3, 4, 5, 6));
-        test.equal(m2.eod().valueOf(), m2.hours(23).minutes(59).seconds(59).milliseconds(999).valueOf(), "Eod should equal manual hours/mins/seconds");
-        
-        test.done();
-    },
-    
+exports.end_start_of = {
     "start of year" : function(test) {
         test.expect(8);
 
@@ -47,13 +10,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 0, "strip out the month");
         test.equal(m.date(), 1, "strip out the day");
-        test.equal(m.hours(), 0, "strip out the hours"); 
-        test.equal(m.minutes(), 0, "strip out the minutes"); 
-        test.equal(m.seconds(), 0, "strip out the seconds"); 
+        test.equal(m.hours(), 0, "strip out the hours");
+        test.equal(m.minutes(), 0, "strip out the minutes");
+        test.equal(m.seconds(), 0, "strip out the seconds");
         test.equal(m.milliseconds(), 0, "strip out the milliseconds");
         test.done();
     },
-    
+
     "end of year" : function(test) {
         test.expect(8);
 
@@ -63,13 +26,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 11, "set the month");
         test.equal(m.date(), 31, "set the day");
-        test.equal(m.hours(), 23, "set the hours"); 
-        test.equal(m.minutes(), 59, "set the minutes"); 
-        test.equal(m.seconds(), 59, "set the seconds"); 
+        test.equal(m.hours(), 23, "set the hours");
+        test.equal(m.minutes(), 59, "set the minutes");
+        test.equal(m.seconds(), 59, "set the seconds");
         test.equal(m.milliseconds(), 999, "set the seconds");
         test.done();
     },
-    
+
     "start of month" : function(test) {
         test.expect(8);
 
@@ -79,13 +42,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 1, "strip out the day");
-        test.equal(m.hours(), 0, "strip out the hours"); 
-        test.equal(m.minutes(), 0, "strip out the minutes"); 
-        test.equal(m.seconds(), 0, "strip out the seconds"); 
+        test.equal(m.hours(), 0, "strip out the hours");
+        test.equal(m.minutes(), 0, "strip out the minutes");
+        test.equal(m.seconds(), 0, "strip out the seconds");
         test.equal(m.milliseconds(), 0, "strip out the milliseconds");
         test.done();
     },
-    
+
     "end of month" : function(test) {
         test.expect(8);
 
@@ -95,13 +58,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 28, "set the day");
-        test.equal(m.hours(), 23, "set the hours"); 
-        test.equal(m.minutes(), 59, "set the minutes"); 
-        test.equal(m.seconds(), 59, "set the seconds"); 
+        test.equal(m.hours(), 23, "set the hours");
+        test.equal(m.minutes(), 59, "set the minutes");
+        test.equal(m.seconds(), 59, "set the seconds");
         test.equal(m.milliseconds(), 999, "set the seconds");
         test.done();
     },
-    
+
     "start of day" : function(test) {
         test.expect(8);
 
@@ -111,13 +74,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 0, "strip out the hours"); 
-        test.equal(m.minutes(), 0, "strip out the minutes"); 
-        test.equal(m.seconds(), 0, "strip out the seconds"); 
+        test.equal(m.hours(), 0, "strip out the hours");
+        test.equal(m.minutes(), 0, "strip out the minutes");
+        test.equal(m.seconds(), 0, "strip out the seconds");
         test.equal(m.milliseconds(), 0, "strip out the milliseconds");
         test.done();
     },
-    
+
     "end of day" : function(test) {
         test.expect(8);
 
@@ -127,13 +90,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 23, "set the hours"); 
-        test.equal(m.minutes(), 59, "set the minutes"); 
-        test.equal(m.seconds(), 59, "set the seconds"); 
+        test.equal(m.hours(), 23, "set the hours");
+        test.equal(m.minutes(), 59, "set the minutes");
+        test.equal(m.seconds(), 59, "set the seconds");
         test.equal(m.milliseconds(), 999, "set the seconds");
         test.done();
     },
-    
+
     "start of hour" : function(test) {
         test.expect(8);
 
@@ -143,13 +106,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 3, "keep the hours"); 
-        test.equal(m.minutes(), 0, "strip out the minutes"); 
-        test.equal(m.seconds(), 0, "strip out the seconds"); 
+        test.equal(m.hours(), 3, "keep the hours");
+        test.equal(m.minutes(), 0, "strip out the minutes");
+        test.equal(m.seconds(), 0, "strip out the seconds");
         test.equal(m.milliseconds(), 0, "strip out the milliseconds");
         test.done();
     },
-    
+
     "end of hour" : function(test) {
         test.expect(8);
 
@@ -159,13 +122,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 3, "keep the hours"); 
-        test.equal(m.minutes(), 59, "set the minutes"); 
-        test.equal(m.seconds(), 59, "set the seconds"); 
+        test.equal(m.hours(), 3, "keep the hours");
+        test.equal(m.minutes(), 59, "set the minutes");
+        test.equal(m.seconds(), 59, "set the seconds");
         test.equal(m.milliseconds(), 999, "set the seconds");
         test.done();
     },
-    
+
     "start of minute" : function(test) {
         test.expect(8);
 
@@ -175,13 +138,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 3, "keep the hours"); 
-        test.equal(m.minutes(), 4, "keep the minutes"); 
-        test.equal(m.seconds(), 0, "strip out the seconds"); 
+        test.equal(m.hours(), 3, "keep the hours");
+        test.equal(m.minutes(), 4, "keep the minutes");
+        test.equal(m.seconds(), 0, "strip out the seconds");
         test.equal(m.milliseconds(), 0, "strip out the milliseconds");
         test.done();
     },
-    
+
     "end of minute" : function(test) {
         test.expect(8);
 
@@ -191,13 +154,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 3, "keep the hours"); 
-        test.equal(m.minutes(), 4, "keep the minutes"); 
-        test.equal(m.seconds(), 59, "set the seconds"); 
+        test.equal(m.hours(), 3, "keep the hours");
+        test.equal(m.minutes(), 4, "keep the minutes");
+        test.equal(m.seconds(), 59, "set the seconds");
         test.equal(m.milliseconds(), 999, "set the seconds");
         test.done();
     },
-    
+
     "start of second" : function(test) {
         test.expect(8);
 
@@ -207,13 +170,13 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 3, "keep the hours"); 
-        test.equal(m.minutes(), 4, "keep the minutes"); 
-        test.equal(m.seconds(), 5, "keep the the seconds"); 
+        test.equal(m.hours(), 3, "keep the hours");
+        test.equal(m.minutes(), 4, "keep the minutes");
+        test.equal(m.seconds(), 5, "keep the the seconds");
         test.equal(m.milliseconds(), 0, "strip out the milliseconds");
         test.done();
     },
-    
+
     "end of second" : function(test) {
         test.expect(8);
 
@@ -223,9 +186,9 @@ exports.eod_sod = {
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
-        test.equal(m.hours(), 3, "keep the hours"); 
-        test.equal(m.minutes(), 4, "keep the minutes"); 
-        test.equal(m.seconds(), 5, "keep the seconds"); 
+        test.equal(m.hours(), 3, "keep the hours");
+        test.equal(m.minutes(), 4, "keep the minutes");
+        test.equal(m.seconds(), 5, "keep the seconds");
         test.equal(m.milliseconds(), 999, "set the seconds");
         test.done();
     },