From 0b549ab759c3191b7442ac1108b87f56880a197c Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Fri, 29 Aug 2014 18:44:41 +0300 Subject: [PATCH] Fix moment.utc with array of formats Fixes #1878 --- moment.js | 3 +++ test/moment/create.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/moment.js b/moment.js index 3b5d65adc..2941b9170 100644 --- a/moment.js +++ b/moment.js @@ -1493,6 +1493,9 @@ for (i = 0; i < config._f.length; i++) { currentScore = 0; tempConfig = copyConfig({}, config); + if (config._useUTC != null) { + tempConfig._useUTC = config._useUTC; + } tempConfig._pf = defaultParsingFlags(); tempConfig._f = config._f[i]; makeDateFromStringAndFormat(tempConfig); diff --git a/test/moment/create.js b/test/moment/create.js index a141d669b..f8f7ac77b 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -943,6 +943,13 @@ exports.create = { true, 'string array + isValid'); test.done(); + }, + + 'utc with array of formats' : function (test) { + test.equal(moment.utc('2014-01-01', ['YYYY-MM-DD', 'YYYY-MM']).format(), + '2014-01-01T00:00:00+00:00', + 'moment.utc works with array of formats'); + test.done(); } }; -- 2.47.2