From: Michal Brašna Date: Wed, 13 May 2015 16:13:45 +0000 (+0200) Subject: Clean the structure of conditons in parseWeekday X-Git-Tag: 2.10.5~34^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cee6e74d56caea332ba8b41da6445d43113e408;p=thirdparty%2Fmoment.git Clean the structure of conditons in parseWeekday --- diff --git a/src/lib/units/day-of-week.js b/src/lib/units/day-of-week.js index a0c7a24ce..a82f12630 100644 --- a/src/lib/units/day-of-week.js +++ b/src/lib/units/day-of-week.js @@ -57,18 +57,20 @@ addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { // HELPERS function parseWeekday(input, locale) { - if (typeof input === 'string') { - if (!isNaN(input)) { - input = parseInt(input, 10); - } - else { - input = locale.weekdaysParse(input); - if (typeof input !== 'number') { - return null; - } - } + if (typeof input !== 'string') { + return input; + } + + if (!isNaN(input)) { + return parseInt(input, 10); } - return input; + + input = locale.weekdaysParse(input); + if (typeof input === 'number') { + return input; + } + + return null; } // LOCALES