]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
fixes issue #3529
authorJohn Crisostomo <johncrisostomo@protonmail.ch>
Sat, 29 Oct 2016 09:18:16 +0000 (17:18 +0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 6 Nov 2016 09:30:55 +0000 (01:30 -0800)
src/lib/create/from-anything.js
src/test/moment/create.js

index 4615090c960bf8dbddab94ac7d450bdc158128f2..11e15089d583cde23dcc8e5e8c598a25b0fa76e7 100644 (file)
@@ -43,10 +43,10 @@ export function prepareConfig (config) {
 
     if (isMoment(input)) {
         return new Moment(checkOverflow(input));
-    } else if (isArray(format)) {
-        configFromStringAndArray(config);
     } else if (isDate(input)) {
         config._d = input;
+    } else if (isArray(format)) {
+        configFromStringAndArray(config);
     } else if (format) {
         configFromStringAndFormat(config);
     }  else {
index 7dc7a5085fdd1cac5ee1b859c34437d7ca3606a8..f5f2e6fc0c44b084115feac0644f03bbf1526bf9 100644 (file)
@@ -75,6 +75,20 @@ test('date', function (assert) {
     assert.equal(moment(new Date(2016,0,1), 'YYYY-MM-DD').format('YYYY-MM-DD'), '2016-01-01', 'If date is provided, format string is ignored');
 });
 
+test('date with a format as an array', function (assert) {
+    var tests = [
+        new Date(2016, 9, 27),
+        new Date(2016, 9, 28),
+        new Date(2016, 9, 29),
+        new Date(2016, 9, 30),
+        new Date(2016, 9, 31)
+    ], i;
+
+    for (i = 0; i < tests.length; i++) {
+        assert.equal(moment(tests[i]).format(), moment(tests[i], ['MM/DD/YYYY'], false).format(), 'Passing date with a format array should still return the correct date');
+    }
+});
+
 test('date mutation', function (assert) {
     var a = new Date();
     assert.ok(moment(a).toDate() !== a, 'the date moment uses should not be the date passed in');