From 1cee6e74d56caea332ba8b41da6445d43113e408 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Bra=C5=A1na?= Date: Wed, 13 May 2015 18:13:45 +0200 Subject: [PATCH] Clean the structure of conditons in parseWeekday --- src/lib/units/day-of-week.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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 -- 2.47.2