]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Refactored isBetween, related to #2991
authorIskren Chernev <iskren.chernev@gmail.com>
Sat, 16 Apr 2016 06:57:46 +0000 (23:57 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 16 Apr 2016 06:57:46 +0000 (23:57 -0700)
src/lib/moment/compare.js

index f35a72e06812a54bd0369d63b58e03901ce13038..b26bac633c4c697aa9e556603fbdac4c00be6e36 100644 (file)
@@ -30,14 +30,9 @@ export function isBefore (input, units) {
 }
 
 export function isBetween (from, to, units, inclusivity) {
-    if (inclusivity === '(]') {
-        return this.isAfter(from, units) && this.isSameOrBefore(to, units);
-    }else if (inclusivity === '[)') {
-        return this.isSameOrAfter(from, units) && this.isBefore(to, units);
-    }else if (inclusivity === '[]') {
-        return !(this.isBefore(from, units) || this.isAfter(to, units));
-    }
-    return this.isAfter(from, units) && this.isBefore(to, units);
+    inclusivity = inclusivity || '()';
+    return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
+        (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
 }
 
 export function isSame (input, units) {