exports.create = {
"array" : function(test) {
test.expect(8);
- test.ok(moment([2010]).native() instanceof Date, "[2010]");
- test.ok(moment([2010, 1]).native() instanceof Date, "[2010, 1]");
- test.ok(moment([2010, 1, 12]).native() instanceof Date, "[2010, 1, 12]");
- test.ok(moment([2010, 1, 12, 1]).native() instanceof Date, "[2010, 1, 12, 1]");
- test.ok(moment([2010, 1, 12, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1]");
- test.ok(moment([2010, 1, 12, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1]");
- test.ok(moment([2010, 1, 12, 1, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1, 1]");
+ test.ok(moment([2010]).toDate() instanceof Date, "[2010]");
+ test.ok(moment([2010, 1]).toDate() instanceof Date, "[2010, 1]");
+ test.ok(moment([2010, 1, 12]).toDate() instanceof Date, "[2010, 1, 12]");
+ test.ok(moment([2010, 1, 12, 1]).toDate() instanceof Date, "[2010, 1, 12, 1]");
+ test.ok(moment([2010, 1, 12, 1, 1]).toDate() instanceof Date, "[2010, 1, 12, 1, 1]");
+ test.ok(moment([2010, 1, 12, 1, 1, 1]).toDate() instanceof Date, "[2010, 1, 12, 1, 1, 1]");
+ test.ok(moment([2010, 1, 12, 1, 1, 1, 1]).toDate() instanceof Date, "[2010, 1, 12, 1, 1, 1, 1]");
test.deepEqual(moment(new Date(2010, 1, 14, 15, 25, 50, 125)), moment([2010, 1, 14, 15, 25, 50, 125]), "constructing with array === constructing with new Date()");
test.done();
},
"number" : function(test) {
test.expect(2);
- test.ok(moment(1000).native() instanceof Date, "1000");
+ test.ok(moment(1000).toDate() instanceof Date, "1000");
test.ok((moment(1000).valueOf() === 1000), "testing valueOf");
test.done();
},
"date" : function(test) {
test.expect(1);
- test.ok(moment(new Date()).native() instanceof Date, "new Date()");
+ test.ok(moment(new Date()).toDate() instanceof Date, "new Date()");
test.done();
},
"moment" : function(test) {
test.expect(2);
- test.ok(moment(moment()).native() instanceof Date, "moment(moment())");
- test.ok(moment(moment(moment())).native() instanceof Date, "moment(moment(moment()))");
+ test.ok(moment(moment()).toDate() instanceof Date, "moment(moment())");
+ test.ok(moment(moment(moment())).toDate() instanceof Date, "moment(moment(moment()))");
test.done();
},
"undefined" : function(test) {
test.expect(1);
- test.ok(moment().native() instanceof Date, "undefined");
+ test.ok(moment().toDate() instanceof Date, "undefined");
test.done();
},
"string without format" : function(test) {
test.expect(2);
- test.ok(moment("Aug 9, 1995").native() instanceof Date, "Aug 9, 1995");
- test.ok(moment("Mon, 25 Dec 1995 13:30:00 GMT").native() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT");
+ test.ok(moment("Aug 9, 1995").toDate() instanceof Date, "Aug 9, 1995");
+ test.ok(moment("Mon, 25 Dec 1995 13:30:00 GMT").toDate() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT");
test.done();
},
"string with format (timezone)" : function(test) {
test.expect(8);
- test.equal(moment('5 -0700', 'H ZZ').native().getUTCHours(), 12, 'parse hours "5 -0700" ---> "H ZZ"');
- test.equal(moment('5 -07:00', 'H Z').native().getUTCHours(), 12, 'parse hours "5 -07:00" ---> "H Z"');
- test.equal(moment('5 -0730', 'H ZZ').native().getUTCMinutes(), 30, 'parse hours "5 -0730" ---> "H ZZ"');
- test.equal(moment('5 -07:30', 'H Z').native().getUTCMinutes(), 30, 'parse hours "5 -07:30" ---> "H Z"');
- test.equal(moment('5 +0100', 'H ZZ').native().getUTCHours(), 4, 'parse hours "5 +0100" ---> "H ZZ"');
- test.equal(moment('5 +01:00', 'H Z').native().getUTCHours(), 4, 'parse hours "5 +01:00" ---> "H Z"');
- test.equal(moment('5 +0130', 'H ZZ').native().getUTCMinutes(), 30, 'parse hours "5 +0130" ---> "H ZZ"');
- test.equal(moment('5 +01:30', 'H Z').native().getUTCMinutes(), 30, 'parse hours "5 +01:30" ---> "H Z"');
+ test.equal(moment('5 -0700', 'H ZZ').toDate().getUTCHours(), 12, 'parse hours "5 -0700" ---> "H ZZ"');
+ test.equal(moment('5 -07:00', 'H Z').toDate().getUTCHours(), 12, 'parse hours "5 -07:00" ---> "H Z"');
+ test.equal(moment('5 -0730', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours "5 -0730" ---> "H ZZ"');
+ test.equal(moment('5 -07:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours "5 -07:30" ---> "H Z"');
+ test.equal(moment('5 +0100', 'H ZZ').toDate().getUTCHours(), 4, 'parse hours "5 +0100" ---> "H ZZ"');
+ test.equal(moment('5 +01:00', 'H Z').toDate().getUTCHours(), 4, 'parse hours "5 +01:00" ---> "H Z"');
+ test.equal(moment('5 +0130', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours "5 +0130" ---> "H ZZ"');
+ test.equal(moment('5 +01:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours "5 +01:30" ---> "H Z"');
test.done();
},