config._a = input.slice(0);
dateFromArray(config);
} else {
- config._d = input instanceof Date ? input : new Date(input);
+ config._d = input instanceof Date ? new Date(+input) : new Date(input);
}
}
test.done();
},
+ "date mutation" : function(test) {
+ test.expect(1);
+ var a = new Date();
+ test.ok(moment(a).toDate() !== a, "the date moment uses should not be the date passed in");
+ test.done();
+ },
+
"moment" : function(test) {
test.expect(2);
test.ok(moment(moment()).toDate() instanceof Date, "moment(moment())");
exports.mutable = {
"manipulation methods" : function (test) {
-
+
var mutableMethods = {
'year': function (m){ return m.year(2011); },
'month': function (m){ return m.month(1); },
for (method in mutableMethods) {
if (mutableMethods.hasOwnProperty(method)) {
- var d = new Date();
- var d2 = mutableMethods[method](moment(d)).toDate();
+ var d = moment();
+ var d2 = mutableMethods[method](d);
test.equal(d, d2, method + "() should be mutable");
}
}
},
"non mutable methods" : function (test) {
-
+
var nonMutableMethods = {
'sod': function (m){ return m.sod() },
'eod': function (m){ return m.eod() }