export function Moment(config) {
copyConfig(this, config);
this._d = new Date(config._d != null ? config._d.getTime() : NaN);
+ if (!this.isValid()) this._d = new Date(NaN);
// Prevent infinite loop in case updateOffset creates new moment
// objects.
if (updateInProgress === false) {
assert.ok(moment('02:30 p more extra stuff', 'hh:mm a').isValid(), 'because other tokens were parsed, date is valid');
assert.ok(moment('1/1/2016 extra data', ['a', 'M/D/YYYY']).isValid(), 'took second format, does not pick up on meridiem parsed from first format (good copy)');
});
+
+test('invalid dates return invalid for methods that access the _d prop', function (assert) {
+ var momentAsDate = moment(['2015', '12', '1']).toDate()
+ assert.equal(momentAsDate, 'Invalid Date', 'toDate returns invalid');
+});