},
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;
},
},
"min" : function (test) {
- test.expect(10);
+ test.expect(8);
var now = moment(),
future = now.clone().add(1, 'month'),
// 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");
},
"max" : function (test) {
- test.expect(10);
+ test.expect(8);
var now = moment(),
future = now.clone().add(1, 'month'),
// 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");