Skip to content

Commit

Permalink
Refactored isBetween, related to moment#2991
Browse files Browse the repository at this point in the history
  • Loading branch information
ichernev committed Apr 16, 2016
1 parent 90efd78 commit 8b4a7ac
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/lib/moment/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8b4a7ac

Please sign in to comment.