]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Clean the structure of conditons in parseWeekday
authorMichal Brašna <michal.brasna@gmail.com>
Wed, 13 May 2015 16:13:45 +0000 (18:13 +0200)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 12 Jul 2015 23:37:27 +0000 (16:37 -0700)
src/lib/units/day-of-week.js

index a0c7a24ce775151b1097166f0a82a3e2951f7fe9..a82f126309d2fd750455eabad14cafd1a114cca9 100644 (file)
@@ -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