From: Iskren Chernev Date: Fri, 29 Aug 2014 15:44:41 +0000 (+0300) Subject: Fix moment.utc with array of formats X-Git-Tag: 2.8.3~12^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1895%2Fhead;p=thirdparty%2Fmoment.git Fix moment.utc with array of formats Fixes #1878 --- 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(); } };