]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix regression outlined in #2512 2515/head
authorIskren Chernev <iskren.chernev@gmail.com>
Mon, 27 Jul 2015 16:39:57 +0000 (09:39 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Mon, 27 Jul 2015 16:57:36 +0000 (09:57 -0700)
src/lib/moment/constructor.js
src/test/moment/create.js

index b29b3d7e128466dd3607bc1aa1fc6fcaf1cc62a1..f5f3da0fb0ab49122fc57b125bbff81d83c0ad8a 100644 (file)
@@ -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) {
index 202287a4ef24e9204401534b0c3af783f178dc7c..9afe7b67340029dcc623367fec6ac32cbd20445d 100644 (file)
@@ -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');