icambron/twix.js — pull request #8 by suzannehamilton (2013-04-21 17:21:17+00:00)
Title: Handling adjacent time ranges with overlaps()

This patch fixes a possible bug in the behavior of the overlaps() method for the edge case of two adjacent time ranges.

In the existing code, all-day ranges overlap if they share a day, which is the behavior I'd expect:

```javascript
var range1 = moment("1982-05-25").twix("1982-05-27", true);
var range2 = moment("1982-05-27").twix("1982-05-29", true);

range1.overlaps(range2); //=> true
```

But overlaps() also returns true for two ranges which are immediately adjacent:

```javascript
var range1 = moment("1982-05-27 08:00").twix("1982-05-27 09:00");
var range2 = moment("1982-05-27 09:00").twix("1982-05-27 10:00");

range1.overlaps(range2); //=> true
```

Intuitively, I'd expect this to actually return _false_. Comparing it to similar libraries, the overlaps() method for Java's Joda-Time intervals also [returns false in this situation](http://joda-time.sourceforge.net/apidocs/org/joda/time/base/AbstractInterval.html#overlaps).

I've rewritten the overlaps() method so that it still returns true in the first (all-day) case, but returns false in the second, and added some tests to cover both cases.

I'm submitting a pull request because this edge-case isn't covered by the existing tests, so I'm guessing it's a bug rather than the intended behavior.

(This is the first pull request I've ever made on GitHub, so apologies if I've made any mistakes in submitting it!)