From: Iskren Chernev Date: Mon, 27 Jul 2015 16:39:57 +0000 (-0700) Subject: Fix regression outlined in #2512 X-Git-Tag: 2.10.6~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2515%2Fhead;p=thirdparty%2Fmoment.git Fix regression outlined in #2512 --- diff --git a/src/lib/moment/constructor.js b/src/lib/moment/constructor.js index b29b3d7e1..f5f3da0fb 100644 --- a/src/lib/moment/constructor.js +++ b/src/lib/moment/constructor.js @@ -58,7 +58,7 @@ var updateInProgress = false; // Moment prototype object export function Moment(config) { copyConfig(this, config); - this._d = new Date(config._d.getTime()); + this._d = new Date(config._d != null ? config._d.getTime() : NaN); // Prevent infinite loop in case updateOffset creates new moment // objects. if (updateInProgress === false) { diff --git a/src/test/moment/create.js b/src/test/moment/create.js index 202287a4e..9afe7b673 100644 --- a/src/test/moment/create.js +++ b/src/test/moment/create.js @@ -112,6 +112,11 @@ test('undefined', function (assert) { assert.ok(moment().toDate() instanceof Date, 'undefined'); }); +test('iso with bad input', function (assert) { + assert.ok(!moment('a', moment.ISO_8601).isValid(), 'iso parsing with invalid string'); + assert.ok(!moment('a', moment.ISO_8601, true).isValid(), 'iso parsing with invalid string, strict'); +}); + test('iso format 24hrs', function (assert) { assert.equal(moment('2014-01-01T24:00:00.000').format('YYYY-MM-DD[T]HH:mm:ss.SSS'), '2014-01-02T00:00:00.000', 'iso format with 24:00 localtime');