From: Tim Wood Date: Mon, 3 Jun 2013 17:21:27 +0000 (-0700) Subject: Removing 'now' option on min/max X-Git-Tag: 2.1.0~27^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F800%2Fhead;p=thirdparty%2Fmoment.git Removing 'now' option on min/max --- diff --git a/moment.js b/moment.js index 1adf58d21..52bd737ab 100644 --- a/moment.js +++ b/moment.js @@ -1361,20 +1361,12 @@ }, min: function (other) { - if (typeof other === "string" && other.toLowerCase() === "now") { - other = moment(); - } else { - other = moment.apply(null, arguments); - } + other = moment.apply(null, arguments); return other < this ? this : other; }, max: function (other) { - if (typeof other === "string" && other.toLowerCase() === "now") { - other = moment(); - } else { - other = moment.apply(null, arguments); - } + other = moment.apply(null, arguments); return other > this ? this : other; }, diff --git a/test/moment/min_max.js b/test/moment/min_max.js index 9ede27ce5..da75c485a 100644 --- a/test/moment/min_max.js +++ b/test/moment/min_max.js @@ -12,7 +12,7 @@ exports.min_max = { }, "min" : function (test) { - test.expect(10); + test.expect(8); var now = moment(), future = now.clone().add(1, 'month'), @@ -22,12 +22,10 @@ exports.min_max = { // two moments are off by a millisecond. test.ok(Math.abs(past.min(now).diff(now)) < 2, "A past date with the minimum of now should be now"); - test.ok(Math.abs(past.min('now').diff(now)) < 2, "A past date with the minimum of 'now' should be now"); test.ok(Math.abs(past.min().diff(now)) < 2, "A past date with the minimum of implied now should be now"); test.ok(Math.abs(past.min(future).diff(future)) < 2, "A past date with the minimum of the future should be the future date"); test.ok(Math.abs(future.min(now).diff(future)) < 2, "A future date with the minimum of now should be the future"); - test.ok(Math.abs(future.min('now').diff(future)) < 2, "A future date with the minimum of 'now' should be the future"); test.ok(Math.abs(future.min().diff(future)) < 2, "A future date with the minimum of implied now should be the future"); test.ok(Math.abs(future.min(past).diff(future)) < 2, "A future date with the minimum of the past should be the future"); @@ -38,7 +36,7 @@ exports.min_max = { }, "max" : function (test) { - test.expect(10); + test.expect(8); var now = moment(), future = now.clone().add(1, 'month'), @@ -48,12 +46,10 @@ exports.min_max = { // two moments are off by a millisecond. test.ok(Math.abs(past.max(now).diff(past)) < 2, "A past date with the maximum of now should be the past"); - test.ok(Math.abs(past.max('now').diff(past)) < 2, "A past date with the maximum of 'now' should be the past"); test.ok(Math.abs(past.max().diff(past)) < 2, "A past date with the maximum of implied now should be the past"); test.ok(Math.abs(past.max(future).diff(past)) < 2, "A past date with the maximum of the future should be the past"); test.ok(Math.abs(future.max(now).diff(now)) < 2, "A future date with the maximum of now should be now"); - test.ok(Math.abs(future.max('now').diff(now)) < 2, "A future date with the maximum of 'now' should be now"); test.ok(Math.abs(future.max().diff(now)) < 2, "A future date with the maximum of implied now should be now"); test.ok(Math.abs(future.max(past).diff(past)) < 2, "A future date with the maximum of the past should be the past");