• passes: 282
  • failures: 0
  • duration: 0.26s
  • plugin

    • static constructor

      • is the same as instantiating via the contructor0ms ‣

        assertEqual('function', typeof moment.twix);
        return assertTwixEqual(new Twix('1982-05-25', '1983-05-25', true), moment.twix('1982-05-25', '1983-05-25', true));
      • uses the parse format for both dates0ms ‣

        return assertTwixEqual(new Twix(moment('2012-05-25'), moment('2013-05-25'), false), moment.twix('05/25/2012', '05/25/2013', 'MM/DD/YYYY'));
    • create from a member

      • is a function0ms ‣

        return assertEqual('function', typeof (moment().twix));
      • is the same as instantiating via the contructor0ms ‣

        return assertTwixEqual(new Twix('1982-05-25', '1983-05-25', false), moment('1982-05-25').twix('1983-05-25'));
      • accepts an allDay argument0ms ‣

        var t;
        t = moment('1982-05-25').twix('1983-05-25', true);
        return assertEqual(t.allDay, true);
      • uses the parse format1ms ‣

        return assertTwixEqual(new Twix(moment('2012-05-25'), moment('2013-05-25'), false), moment('2012-05-25').twix('05/25/2013', 'MM/DD/YYYY'));
      • uses a parseStrict object argument1ms ‣

        var t;
        t = moment('1981-05-25').twix('A05/25/1982', 'MM/DD/YYYY', {
          parseStrict: true
        });
        assertEqual(t.end().isValid(), false);
        t = moment('1981-05-25').twix('05/25/1982', 'MM/DD/YYYY', {
          parseStrict: true
        });
        return assertEqual(t.end().isValid(), true);
      • uses an allDay option argument0ms ‣

        var t;
        t = moment('1981-05-25').twix('05/25/1982', 'MM/DD/YYYY', {
          allDay: true
        });
        assertEqual(t.allDay, true);
        t = moment('1981-05-25').twix('1982-05-25', {
          allDay: true
        });
        return assertEqual(t.allDay, true);
    • moment.forDuration()

      • constructs a twix0ms ‣

        var duration, from, to, twix;
        from = thisYear('05-25');
        to = thisYear('05-26');
        duration = moment.duration(to.diff(from));
        twix = from.forDuration(duration);
        return assertTwixEqual(new Twix(from, to), twix);
      • constructs an all-day twix0ms ‣

        var duration, from, to, twix;
        from = thisYear('05-25');
        to = thisYear('05-26');
        duration = moment.duration(to.diff(from));
        twix = from.forDuration(duration, true);
        return assertTwixEqual(new Twix(from, to, true), twix);
    • duration.afterMoment()

      • contructs a twix0ms ‣

        var d, twix;
        d = moment.duration(2, 'days');
        twix = d.afterMoment(thisYear('05-25'));
        return assertTwixEqual(new Twix(thisYear('05-25'), thisYear('05-27')), twix);
      • can use text0ms ‣

        var d, twix;
        d = moment.duration(2, 'days');
        twix = d.afterMoment('1982-05-25');
        return assertTwixEqual(new Twix('1982-05-25', '1982-05-27'), twix);
      • contructs an all-day twix1ms ‣

        var d, twix;
        d = moment.duration(2, 'days');
        twix = d.afterMoment(thisYear('05-25'), true);
        return assertTwixEqual(new Twix(thisYear('05-25'), thisYear('05-27'), true), twix);
    • duration.beforeMoment()

      • contructs a twix0ms ‣

        var d, twix;
        d = moment.duration(2, 'days');
        twix = d.beforeMoment(thisYear('05-25'));
        return assertTwixEqual(new Twix(thisYear('05-23'), thisYear('05-25')), twix);
      • can use text0ms ‣

        var d, twix;
        d = moment.duration(2, 'days');
        twix = d.beforeMoment('1982-05-25');
        return assertTwixEqual(new Twix('1982-05-23', '1982-05-25'), twix);
      • contructs an all-day twix0ms ‣

        var d, twix;
        d = moment.duration(2, 'days');
        twix = d.beforeMoment(thisYear('05-25'), true);
        return assertTwixEqual(new Twix(thisYear('05-23'), thisYear('05-25'), true), twix);
  • start()

    • returns the start of the range0ms ‣

      return assertMomentEqual(moment('1982-05-25'), moment('1982-05-25').twix('1983-10-14').start());
    • returns the start of the start day for all day ranges1ms ‣

      return assertMomentEqual(moment('1982-05-25'), moment('1982-05-25T04:45:45').twix('1983-10-14', true).start());
    • returns start time for for non-all-day ranges0ms ‣

      return assertMomentEqual(moment('1982-05-25T04:45:45'), moment('1982-05-25T04:45:45').twix('1983-10-14T01:01:01').start());
  • end()

    • returns the end of the range0ms ‣

      return assertMomentEqual(moment('1983-10-14'), moment('1982-05-25').twix('1983-10-14').end());
    • returns the start of the end day for all day ranges0ms ‣

      return assertMomentEqual(moment('1983-10-14'), moment('1982-05-25').twix('1983-10-14T09:30:23', true).end());
    • returns end time for for non-all-day ranges0ms ‣

      return assertMomentEqual(moment('1983-10-14T01:01:01'), moment('1982-05-25T04:45:45').twix('1983-10-14T01:01:01').end());
  • isSame()

    • year

      • returns true if they're the same year0ms ‣

        return assertEqual(true, moment('1982-05-25').twix('1982-10-14').isSame('year'));
      • returns false if they're different years0ms ‣

        return assertEqual(false, moment('1982-05-25').twix('1983-10-14').isSame('year'));
    • day

      • returns true if they're the same day1ms ‣

        return assertEqual(true, moment('1982-05-25T05:30').twix('1982-05-25T19:30').isSame('day'));
      • returns false if they're different days day0ms ‣

        return assertEqual(false, moment('1982-05-25T05:30').twix('1982-05-26T19:30').isSame('day'));
      • returns true they're in different UTC days but the same local days0ms ‣

        return assertEqual(true, moment('1982-05-25T05:30').twix('1982-05-25T23:30').isSame('day'));
  • length()

    • no arguments

      • returns milliseconds1ms ‣

        var mom;
        mom = moment();
        return assertEqual(60 * 1000, mom.twix(mom.clone().add(1, 'minute')).length());
    • floating point

      • returns a decimal0ms ‣

        var range;
        range = moment('1982-05-25T00:00').twix('1982-05-25T06:30');
        return assertEqual(6.5, range.length('hours', true));
    • days

      • returns 1 for yesterday - today0ms ‣

        return assertEqual(1, yesterday().twix(moment()).length('days'));
      • returns 1 for a one-day all-day range1ms ‣

        return assertEqual(1, moment().twix(moment(), true).length('days'));
      • returns 2 for a two-day all-day range0ms ‣

        return assertEqual(2, yesterday().twix(moment(), true).length('days'));
    • other

      • returns the right number for a years0ms ‣

        return assertEqual(16, moment('1996-02-17').twix('2012-08-14').length('years'));
      • returns the right number for a months1ms ‣

        return assertEqual(197, moment('1996-02-17').twix('2012-08-14').length('months'));
  • count()

    • days

      • returns 1 inside a day0ms ‣

        var end, range, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '14:00');
        range = moment(start).twix(end);
        return assertEqual(1, range.count('days'));
      • returns 2 if the range crosses midnight0ms ‣

        var end, range, start;
        start = thisYear('05-25', '16:00');
        end = thisYear('05-26', '03:00');
        range = moment(start).twix(end);
        return assertEqual(2, range.count('days'));
      • works fine for all-day ranges0ms ‣

        var end, range, start;
        start = thisYear('05-25');
        end = thisYear('05-26');
        range = moment(start).twix(end, true);
        return assertEqual(2, range.count('days'));
    • years

      • returns 1 inside a year0ms ‣

        var end, start;
        start = thisYear('05-25');
        end = thisYear('05-26');
        return assertEqual(1, moment(start).twix(end).count('year'));
      • returns 2 if the range crosses Jan 10ms ‣

        var end, start;
        start = thisYear('05-25');
        end = nextYear('05-26');
        return assertEqual(2, moment(start).twix(end).count('year'));
  • countInner()

    • days

      • defaults to milliseconds0ms ‣

        var end, range, start;
        start = thisYear('05-25', '13:00');
        end = thisYear('05-25', '13:01');
        range = moment(start).twix(end);
        return assertEqual(60000, range.countInner());
      • returns 0 inside a day0ms ‣

        var end, range, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '14:00');
        range = moment(start).twix(end);
        return assertEqual(0, range.countInner('days'));
      • returns 0 if the range crosses midnight but is still < 24 hours1ms ‣

        var end, range, start;
        start = thisYear('05-25', '16:00');
        end = thisYear('05-26', '03:00');
        range = moment(start).twix(end);
        return assertEqual(0, range.countInner('days'));
      • returns 0 if the range is > 24 hours but still doesn't cover a full day0ms ‣

        var end, range, start;
        start = thisYear('05-25', '16:00');
        end = thisYear('05-26', '17:00');
        range = moment(start).twix(end);
        return assertEqual(0, range.countInner('days'));
      • returns 1 if the range includes one full day0ms ‣

        var end, range, start;
        start = thisYear('05-24', '16:00');
        end = thisYear('05-26', '17:00');
        range = moment(start).twix(end);
        return assertEqual(1, range.countInner('days'));
      • returns 1 if the range includes one full day barely1ms ‣

        var end, range, start;
        start = thisYear('05-24');
        end = thisYear('05-25');
        range = moment(start).twix(end);
        return assertEqual(1, range.countInner('days'));
      • returns 2 if the range includes two full days0ms ‣

        var end, range, start;
        start = thisYear('05-23', '16:00');
        end = thisYear('05-26', '17:00');
        range = moment(start).twix(end);
        return assertEqual(2, range.countInner('days'));
      • returns 1 for a one-day all-day range0ms ‣

        var end, range, start;
        start = thisYear('05-25');
        end = thisYear('05-25');
        range = moment(start).twix(end, true);
        return assertEqual(1, range.countInner('days'));
      • returns 2 for a two-day all-day range1ms ‣

        var end, range, start;
        start = thisYear('05-25');
        end = thisYear('05-26');
        range = moment(start).twix(end, true);
        return assertEqual(2, range.countInner('days'));
      • doesn't muck with the twix object1ms ‣

        var end, range, start;
        start = thisYear('05-25');
        end = thisYear('05-26');
        range = moment(start).twix(end);
        range.countInner('years');
        assertMomentEqual(thisYear('05-25'), range.start());
        return assertMomentEqual(thisYear('05-26'), range.end());
  • iterate()

    • duration

      • provides 4 periods of 20 minutes (as duration) if the range is 1 hour1ms ‣

        var duration, end, iter, results, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '04:00');
        duration = moment.duration(20, 'minutes');
        iter = start.twix(end).iterate(duration);
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        assertSameMinute(start.clone().add(20, 'minutes'), results[1]);
        return assertEqual(4, results.length);
      • provides 5 periods of 2 hours, 30 minutes and 20 seconds if the range is 10 hours and 2 minutes1ms ‣

        var duration, end, iter, results, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '13:01:20');
        duration = moment.duration({
          hours: 2,
          minutes: 30,
          seconds: 20
        });
        iter = start.twix(end).iterate(duration);
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        assertSameMinute(start.clone().add(30, 'minutes').add(2, 'hours').add(20, 'seconds'), results[1]);
        return assertEqual(5, results.length);
    • minutes

      • provides 4 periods of 20 minutes if the range is 1 hour1ms ‣

        var end, iter, results, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '04:00');
        iter = start.twix(end).iterate(20, 'minutes', 0);
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        assertSameMinute(start.clone().add(20, 'minutes'), results[1]);
        return assertEqual(4, results.length);
    • days

      • provides 1 day if the range includes 1 day1ms ‣

        var end, iter, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '14:00');
        iter = start.twix(end).iterate('days');
        assertSameDay(thisYear('05-25'), iter.next());
        return assertEqual(null, iter.next());
      • provides 2 days if the range crosses midnight0ms ‣

        var end, iter, start;
        start = thisYear('05-25', '16:00');
        end = thisYear('05-26', '03:00');
        iter = start.twix(end).iterate('days');
        assertSameDay(start, iter.next());
        assertSameDay(end, iter.next());
        return assertEqual(null, iter.next());
      • provides 366 days if the range is a year3ms ‣

        var end, iter, results, start;
        start = moment('2014-05-25T16:00');
        end = moment('2014-05-25T03:00').add(1, 'year');
        iter = start.twix(end).iterate('days');
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        return assertEqual(366, results.length);
      • provides 1 day for an all-day range0ms ‣

        var end, iter, start;
        start = thisYear('05-25');
        end = thisYear('05-25');
        iter = start.twix(end, true).iterate('days');
        assertSameDay(thisYear('05-25'), iter.next());
        return assertEqual(null, iter.next());
      • doesn't generate extra days when there's a min time0ms ‣

        var end, iter, start;
        start = thisYear('05-25', '16:00');
        end = thisYear('05-26', '03:00');
        iter = start.twix(end).iterate('days', 4);
        assertSameDay(thisYear('05-25'), iter.next());
        return assertEqual(null, iter.next());
      • provides 1 day for all-day ranges when there's a min time1ms ‣

        var end, iter, start;
        start = thisYear('05-25');
        end = thisYear('05-25');
        iter = start.twix(end, true).iterate('days', 4);
        assertEqual(true, iter.hasNext());
        assertSameDay(start, iter.next());
        assertEqual(false, iter.hasNext());
        return assertEqual(null, iter.next());
    • months

      • provides 3 months for an all-day range with three months in it1ms ‣

        var dateRange, end, iter, start;
        start = moment('2014-10-01');
        end = moment('2014-12-01');
        dateRange = start.twix(end, true);
        iter = dateRange.iterate('M');
        assertEqual(true, iter.hasNext());
        assertSameDay(start, iter.next());
        assertEqual(true, iter.hasNext());
        assertSameDay(moment('2014-11-01'), iter.next());
        assertEqual(true, iter.hasNext());
        return assertSameDay(end, iter.next());
    • years

      • provides 1 year if the range happens inside a year0ms ‣

        var end, iter, start;
        start = thisYear('05-25');
        end = thisYear('05-25');
        iter = start.twix(end).iterate('years');
        assertSameYear(start, iter.next());
        return assertEqual(null, iter.next());
      • provides 2 years if the range crosses Jan 10ms ‣

        var end, iter, start;
        start = thisYear('05-25');
        end = nextYear('05-26');
        iter = start.twix(end).iterate('years');
        assertSameYear(start, iter.next());
        assertSameYear(end, iter.next());
        return assertEqual(null, iter.next());
      • doesn't generate extra years when there's a min time0ms ‣

        var end, iter, range, start;
        start = thisYear('05-25', '16:00');
        end = nextYear('01-01', '03:00');
        range = moment(start).twix(end);
        iter = range.iterate('years', 4);
        assertSameYear(thisYear('05-25'), iter.next());
        return assertEqual(null, iter.next());
  • iterateInner()

    • duration

      • provides 3 periods of 20 minutes (as duration) if the range is 1 hour0ms ‣

        var duration, end, iter, results, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '04:00');
        duration = moment.duration(20, 'minutes');
        iter = start.twix(end).iterateInner(duration);
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        assertSameMinute(start.clone().add(20, 'minutes'), results[1]);
        return assertEqual(3, results.length);
      • provides 4 periods of 2 hours, 30 minutes and 20 seconds if the range is 10 hours and 1 minute 20 seconds0ms ‣

        var duration, end, iter, results, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '13:01:20');
        duration = moment.duration({
          hours: 2,
          minutes: 30,
          seconds: 20
        });
        iter = start.twix(end).iterateInner(duration);
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        assertSameMinute(start.clone().add(30, 'minutes').add(2, 'hours').add(20, 'seconds'), results[1]);
        return assertEqual(4, results.length);
    • minutes

      • provides 3 periods of 20 minutes if the range is 1 hour0ms ‣

        var end, iter, results, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '04:00');
        iter = start.twix(end).iterateInner('minutes', 20);
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        assertSameMinute(start.clone().add(20, 'minutes'), results[1]);
        return assertEqual(3, results.length);
      • provides 24 periods of 60 minutes if the range is 24 hours1ms ‣

        var end, iter, results, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-26', '03:00');
        iter = start.twix(end).iterateInner('minutes', 60);
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        return assertEqual(24, results.length);
    • hours

      • provides 3 periods of 2 hours if the range is 7 hours1ms ‣

        var end, iter, results, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '10:00');
        iter = start.twix(end).iterateInner(2, 'hours');
        results = (function() {
          var results1;
          results1 = [];
          while (iter.hasNext()) {
            results1.push(iter.next());
          }
          return results1;
        })();
        assertSameHour(start.clone().add(2, 'hours'), results[1]);
        return assertEqual(3, results.length);
    • days

      • is empty if the range starts and ends the same day1ms ‣

        var end, iter, start;
        start = thisYear('05-25', '03:00');
        end = thisYear('05-25', '14:00');
        iter = start.twix(end).iterateInner('days');
        assertEqual(false, iter.hasNext());
        return assertEqual(null, iter.next());
      • is empty if the range doesn't contain a whole day0ms ‣

        var end, iter, start;
        start = thisYear('05-25', '16:00');
        end = thisYear('05-26', '17:00');
        iter = start.twix(end).iterateInner('days');
        assertEqual(false, iter.hasNext());
        return assertEqual(null, iter.next());
      • provides 1 day if the range contains 1 full day0ms ‣

        var end, iter, start;
        start = thisYear('05-24', '16:00');
        end = thisYear('05-26', '03:00');
        iter = start.twix(end).iterateInner('days');
        assertSameDay(thisYear('05-25'), iter.next());
        return assertEqual(null, iter.next());
      • provides 1 day for an all-day range1ms ‣

        var end, iter, start;
        start = thisYear('05-25');
        end = thisYear('05-25');
        iter = start.twix(end, true).iterateInner('days');
        assertSameDay(thisYear('05-25'), iter.next());
        return assertEqual(null, iter.next());
      • provides 2 days for a two-day all-day range1ms ‣

        var end, iter, start;
        start = thisYear('05-25');
        end = thisYear('05-26');
        iter = start.twix(end, true).iterateInner('days');
        assertEqual(true, iter.hasNext());
        assertSameDay(thisYear('05-25'), iter.next());
        assertEqual(true, iter.hasNext());
        assertSameDay(thisYear('05-26'), iter.next());
        return assertEqual(null, iter.next());
  • humanizeLength()

    • all-day ranges

      • formats single-day correctly0ms ‣

        return assertEqual('all day', new Twix('1982-05-25', '1982-05-25', true).humanizeLength());
      • formats multiday correctly1ms ‣

        return assertEqual('3 days', new Twix('1982-05-25', '1982-05-27', true).humanizeLength());
    • non-all-day ranges

      • formats single-day correctly0ms ‣

        return assertEqual('4 hours', thatDay('12:00', '16:00').humanizeLength());
      • formats multiday correctly1ms ‣

        return assertEqual('2 days', new Twix('1982-05-25', '1982-05-27').humanizeLength());
  • isEmpty()

    • returns true for empty ranges0ms ‣

      return assertEqual(true, thatDay('12:00', '12:00').isEmpty());
    • returns false for non-empty ranges0ms ‣

      return assertEqual(false, thatDay('12:00', '13:00').isEmpty());
    • returns false for 'empty' all-day ranges0ms ‣

      return assertEqual(false, moment('1982-05-25').twix('1982-05-25', true).isEmpty());
  • asDuration()

    • returns a duration object0ms ‣

      var duration;
      duration = yesterday().twix(tomorrow()).asDuration();
      assertEqual(true, moment.isDuration(duration));
      return assertEqual(2, duration.days());
  • isPast()

    • all-day ranges

      • returns true for days in the past0ms ‣

        return assertEqual(true, yesterday().twix(yesterday(), true).isPast());
      • returns false for today0ms ‣

        var today;
        today = moment().startOf('day');
        return assertEqual(false, today.twix(today, true).isPast());
      • returns false for days in the future0ms ‣

        return assertEqual(false, tomorrow().twix(tomorrow(), true).isPast());
    • non-all-day ranges

      • returns true for the past1ms ‣

        var nearerPast, past;
        past = moment().subtract(3, 'hours');
        nearerPast = moment().subtract(2, 'hours');
        return assertEqual(true, past.twix(nearerPast).isPast());
      • returns false for the future0ms ‣

        var furtherFuture, future;
        future = moment().add(2, 'hours');
        furtherFuture = moment().add(3, 'hours');
        return assertEqual(false, future.twix(furtherFuture).isPast());
  • isFuture()

    • all-day ranges

      • returns false for days in the past0ms ‣

        return assertEqual(false, yesterday().twix(yesterday(), true).isFuture());
      • returns false for today0ms ‣

        var today;
        today = moment().startOf('day');
        return assertEqual(false, today.twix(today, true).isFuture());
      • returns true for days in the future0ms ‣

        return assertEqual(true, tomorrow().twix(tomorrow(), true).isFuture());
    • non-all-day ranges

      • returns false for the past0ms ‣

        var nearerPast, past;
        past = moment().subtract(3, 'hours');
        nearerPast = moment().subtract(3, 'hours');
        return assertEqual(false, past.twix(nearerPast).isFuture());
      • returns true for the future0ms ‣

        var furtherFuture, future;
        future = moment().add(2, 'hours');
        furtherFuture = moment().add(3, 'hours');
        return assertEqual(true, future.twix(furtherFuture).isFuture());
  • isCurrent()

    • all-day ranges

      • returns false for days in the past0ms ‣

        return assertEqual(false, yesterday().twix(yesterday(), true).isCurrent());
      • returns true for today0ms ‣

        var today;
        today = moment().startOf('day');
        return assertEqual(true, today.twix(today, true).isCurrent());
      • returns false for days in the future0ms ‣

        return assertEqual(false, tomorrow().twix(tomorrow(), true).isCurrent());
    • non-all-day ranges

      • returns false for the past0ms ‣

        var nearerPast, past;
        past = moment().subtract(3, 'hours');
        nearerPast = moment().subtract(2, 'hours');
        return assertEqual(false, past.twix(nearerPast).isCurrent());
      • returns false for the future0ms ‣

        var furtherFuture, future;
        future = moment().add(2, 'hours');
        furtherFuture = moment().add(3, 'hours');
        return assertEqual(false, future.twix(furtherFuture).isCurrent());
  • contains()

    • non-all-day

      • returns true for moments inside the range0ms ‣

        return assertEqual(true, range.contains(thisYear('05-25', '06:30')));
      • returns true for moments at the beginning of the range0ms ‣

        return assertEqual(true, range.contains(start));
      • returns true for moments at the end of the range0ms ‣

        return assertEqual(true, range.contains(end));
      • returns false for moments before the range1ms ‣

        return assertEqual(false, range.contains(thisYear('05-25', '05:30')));
      • returns false for moments after the range0ms ‣

        return assertEqual(false, range.contains(thisYear('05-25', '08:30')));
    • all-day

      • returns true for moments inside the range1ms ‣

        return assertEqual(true, range.contains(thisYear('05-25', '06:30')));
      • returns true for moments at the beginning of the range0ms ‣

        return assertEqual(true, range.contains(start));
      • returns true for moments at the end of the range0ms ‣

        return assertEqual(true, range.contains(start.clone().endOf('day')));
      • returns false for moments before the range0ms ‣

        return assertEqual(false, range.contains(thisYear('05-24')));
      • returns false for moments after the end of the range0ms ‣

        return assertEqual(false, range.contains(thisYear('05-26', '00:00:00')));
      • returns false for moments after the range0ms ‣

        return assertEqual(false, range.contains(thisYear('05-26', '00:00:01')));
  • overlaps()

    • non-all-day ranges

      • returns false for a later range1ms ‣

        return assertNoOverlap(someTime, thatDay('09:30', '11:30'));
      • returns false for an earlier range0ms ‣

        return assertNoOverlap(someTime, thatDay('03:30', '04:30'));
      • returns true for a partially later range0ms ‣

        return assertOverlap(someTime, thatDay('08:00', '11:30'));
      • returns true for a partially earlier range0ms ‣

        return assertOverlap(someTime, thatDay('04:30', '06:30'));
      • returns true for an engulfed range0ms ‣

        return assertOverlap(someTime, thatDay('06:30', '07:30'));
      • returns true for an engulfing range0ms ‣

        return assertOverlap(someTime, thatDay('04:30', '09:30'));
      • returns false for a range that starts immediately afterwards0ms ‣

        return assertNoOverlap(someTime, thatDay('08:30', '09:30'));
      • returns false for a range that ends immediately before0ms ‣

        return assertNoOverlap(someTime, thatDay('04:30', '05:30'));
    • one all-day range

      • returns true for a partially later range0ms ‣

        return assertOverlap(thatDay(), new Twix('1982-05-25 20:00', '1982-05-26 05:00'));
      • returns true for a partially earlier range0ms ‣

        return assertOverlap(thatDay(), new Twix('1982-05-24 20:00', '1982-05-25 07:00'));
      • returns true for an engulfed range0ms ‣

        return assertOverlap(thatDay(), someTime);
      • returns true for an engulfing range0ms ‣

        return assertOverlap(thatDay(), new Twix('1982-05-24 20:00', '1982-05-26 05:00'));
      • returns true for a range which starts on the same day1ms ‣

        return assertOverlap(thatDay(), new Twix('1982-05-25', '1982-05-27'));
      • returns true for a range which ends on the same day0ms ‣

        return assertOverlap(thatDay(), new Twix('1982-05-23', '1982-05-25', true));
    • two all-day ranges

      • returns false for a later range0ms ‣

        return assertNoOverlap(someDays, new Twix('1982-05-26', '1982-05-27', true));
      • returns false for an earlier range0ms ‣

        return assertNoOverlap(someDays, new Twix('1982-05-22', '1982-05-23', true));
      • returns true for a partially later range0ms ‣

        return assertOverlap(someDays, new Twix('1982-05-24', '1982-05-26', true));
      • returns true for a partially earlier range0ms ‣

        return assertOverlap(someDays, new Twix('1982-05-22', '1982-05-24', true));
      • returns true for an engulfed range0ms ‣

        return assertOverlap(someDays, new Twix('1982-05-25', '1982-05-25', true));
      • returns true for an engulfing range0ms ‣

        return assertOverlap(someDays, new Twix('1982-05-22', '1982-05-28', true));
  • engulfs()

    • non-all-day ranges

      • returns false for a later range0ms ‣

        return assertNotEngulfing(someTime, thatDay('09:30', '11:30'));
      • returns false for an earlier range0ms ‣

        return assertNotEngulfing(someTime, thatDay('03:30', '04:30'));
      • returns false for a partially later range0ms ‣

        return assertNotEngulfing(someTime, thatDay('08:00', '11:30'));
      • returns false for a partially earlier range1ms ‣

        return assertNotEngulfing(someTime, thatDay('04:30', '06:30'));
      • returns true for an engulfed range0ms ‣

        return assertEngulfing(someTime, thatDay('06:30', '07:30'));
      • returns false for an engulfing range0ms ‣

        return assertNotEngulfing(someTime, thatDay('04:30', '09:30'));
    • one all-day range

      • returns true for a partially later range1ms ‣

        return assertNotEngulfing(thatDay(), new Twix('1982-05-25 20:00', '1982-05-26 05:00'));
      • returns true for a partially earlier range1ms ‣

        return assertNotEngulfing(thatDay(), new Twix('1982-05-24', '20:00', '1982-05-25 07:00'));
      • returns true for an engulfed range0ms ‣

        return assertEngulfing(thatDay(), someTime);
      • returns true for an engulfing range0ms ‣

        return assertNotEngulfing(thatDay(), new Twix('1982-05-24 20:00', '1982-05-26 05:00'));
    • two all-day ranges

      • returns false for a later range0ms ‣

        return assertNotEngulfing(someDays, new Twix('1982-05-26', '1982-05-27', true));
      • returns false for an earlier range0ms ‣

        return assertNotEngulfing(someDays, new Twix('1982-05-22', '1982-05-23', true));
      • returns true for a partially later range0ms ‣

        return assertNotEngulfing(someDays, new Twix('1982-05-24', '1982-05-26', true));
      • returns true for a partially earlier range0ms ‣

        return assertNotEngulfing(someDays, new Twix('1982-05-22', '1982-05-24', true));
      • returns true for an engulfed range0ms ‣

        return assertEngulfing(someDays, new Twix('1982-05-25', '1982-05-25', true));
      • returns true for an engulfing range0ms ‣

        return assertNotEngulfing(someDays, new Twix('1982-05-22', '1982-05-28', true));
  • union()

    • non-all-day ranges

      • spans a later time1ms ‣

        return assertTwixEqual(thatDay('05:30', '11:30'), someTime.union(thatDay('09:30', '11:30')));
      • spans an earlier time1ms ‣

        return assertTwixEqual(thatDay('03:30', '08:30'), someTime.union(thatDay('03:30', '04:30')));
      • spans a partially later range0ms ‣

        return assertTwixEqual(thatDay('05:30', '11:30'), someTime.union(thatDay('08:00', '11:30')));
      • spans a partially earlier range0ms ‣

        return assertTwixEqual(thatDay('04:30', '08:30'), someTime.union(thatDay('04:30', '06:30')));
      • isn't affected by engulfed ranges0ms ‣

        return assertTwixEqual(someTime, someTime.union(thatDay('06:30', '07:30')));
      • becomes an engulfing range0ms ‣

        return assertTwixEqual(thatDay('04:30', '09:30'), someTime.union(thatDay('04:30', '09:30')));
      • spans adjacent ranges0ms ‣

        return assertTwixEqual(thatDay('05:30', '09:30'), someTime.union(thatDay('08:30', '09:30')));
    • one all-day range

      • spans a later time0ms ‣

        return assertTwixEqual(new Twix('1982-05-24 00:00', '1982-05-26 07:00'), someDays.union(new Twix('1982-05-24 20:00', '1982-05-26 07:00')));
      • spans an earlier time0ms ‣

        return assertTwixEqual(new Twix('1982-05-23 08:00', moment('1982-05-26')), someDays.union(new Twix('1982-05-23 08:00', '1982-05-25 07:00')));
      • isn't affected by engulfing ranges0ms ‣

        return assertTwixEqual(new Twix('1982-05-24 00:00', moment('1982-05-26')), someDays.union(someTime));
      • becomes an engulfing range0ms ‣

        return assertTwixEqual(new Twix('1982-05-23 20:00', '1982-05-26 08:30'), someDays.union(new Twix('1982-05-23 20:00', '1982-05-26 08:30')));
    • two all-day ranges

      • spans a later time1ms ‣

        return assertTwixEqual(new Twix('1982-05-24', '1982-05-28', true), someDays.union(new Twix('1982-05-27', '1982-05-28', true)));
      • spans an earlier time0ms ‣

        return assertTwixEqual(new Twix('1982-05-21', '1982-05-25', true), someDays.union(new Twix('1982-05-21', '1982-05-22', true)));
      • spans a partially later time0ms ‣

        return assertTwixEqual(new Twix('1982-05-24', '1982-05-26', true), someDays.union(new Twix('1982-05-25', '1982-05-26', true)));
      • spans a partially earlier time0ms ‣

        return assertTwixEqual(new Twix('1982-05-23', '1982-05-25', true), someDays.union(new Twix('1982-05-23', '1982-05-25', true)));
      • isn't affected by engulfing ranges0ms ‣

        return assertTwixEqual(someDays, someDays.union(thatDay()));
      • becomes an engulfing range0ms ‣

        return assertTwixEqual(someDays, thatDay().union(someDays));
  • intersection()

    • non-all-day ranges

      • does not intersect with a later time0ms ‣

        var intersection;
        intersection = someTime.intersection(thatDay('09:30', '11:30'));
        assertTwixEqual(thatDay('09:30', '08:30'), intersection);
        return assertEqual(false, intersection.isValid());
      • does not intersect with an earlier time0ms ‣

        var intersection;
        intersection = someTime.intersection(thatDay('03:30', '04:30'));
        assertTwixEqual(thatDay('05:30', '04:30'), intersection);
        return assertEqual(false, intersection.isValid());
      • intersects with a partially later range1ms ‣

        return assertTwixEqual(thatDay('08:00', '08:30'), someTime.intersection(thatDay('08:00', '11:30')));
      • intersects with a partially earlier range0ms ‣

        return assertTwixEqual(thatDay('05:30', '06:30'), someTime.intersection(thatDay('04:30', '06:30')));
      • intersects with an engulfed range0ms ‣

        return assertTwixEqual(thatDay('06:30', '07:30'), someTime.intersection(thatDay('06:30', '07:30')));
      • intersects with an engulfing range1ms ‣

        return assertTwixEqual(thatDay('05:30', '08:30'), someTime.intersection(thatDay('04:30', '09:30')));
      • does not intersect an adjacent range (later)0ms ‣

        return assertEqual(0, someTime.intersection(thatDay('08:30', '09:30')).length());
      • does not intersect an adjacent range (earlier)0ms ‣

        return assertEqual(0, someTime.intersection(thatDay('04:30', '05:30')).length());
      • returns self for an identical range0ms ‣

        return assertTwixEqual(someTime, someTime.intersection(someTime));
      • returns self for a time that starts at the same time but ends later0ms ‣

        return assertTwixEqual(someTime, someTime.intersection(thatDay('05:30', '09:30')));
    • one all-day range

      • intersects with a later time1ms ‣

        return assertTwixEqual(new Twix('1982-05-24 20:00', '1982-05-26'), someDays.intersection(new Twix('1982-05-24 20:00', '1982-05-26 07:00')));
      • intersects with an earlier time0ms ‣

        return assertTwixEqual(new Twix('1982-05-24 00:00', '1982-05-25 07:00'), someDays.intersection(new Twix('1982-05-23 08:00', '1982-05-25 07:00')));
      • intersects with an engulfed range0ms ‣

        return assertTwixEqual(new Twix('1982-05-25 05:30', '1982-05-25 08:30'), someDays.intersection(someTime));
      • intersects with an engulfing range0ms ‣

        return assertTwixEqual(new Twix('1982-05-24 00:00', '1982-05-26'), someDays.intersection(new Twix('1982-05-23 20:00', '1982-05-26 08:30')));
    • two all-day ranges

      • does not intersect with a later time0ms ‣

        var intersection;
        intersection = someDays.intersection(new Twix('1982-05-27', '1982-05-28', true));
        assertTwixEqual(new Twix('1982-05-27', '1982-05-25', true), intersection);
        return assertEqual(false, intersection.isValid());
      • does not intersect with an earlier time0ms ‣

        var intersection;
        intersection = someDays.intersection(new Twix('1982-05-21', '1982-05-22', true));
        assertTwixEqual(new Twix('1982-05-24', '1982-05-22', true), intersection);
        return assertEqual(false, intersection.isValid());
      • intersects with a partially later time0ms ‣

        return assertTwixEqual(new Twix('1982-05-25', '1982-05-25', true), someDays.intersection(new Twix('1982-05-25', '1982-05-26', true)));
      • intersects with a partially earlier time0ms ‣

        return assertTwixEqual(new Twix('1982-05-24', '1982-05-25', true), someDays.intersection(new Twix('1982-05-23', '1982-05-25', true)));
      • intersects with an engulfed range1ms ‣

        return assertTwixEqual(thatDay(), someDays.intersection(thatDay()));
      • intersects with an engulfing range0ms ‣

        return assertTwixEqual(thatDay(), thatDay().intersection(someDays));
  • xor()

    • non-all-day ranges

      • returns non-overlapping ranges as-is (later)0ms ‣

        var later, orred;
        later = thatDay('09:30', '11:30');
        orred = someTime.xor(later);
        assertEqual(2, orred.length);
        assertTwixEqual(someTime, orred[0]);
        return assertTwixEqual(later, orred[1]);
      • returns non-overlapping ranges as-is (earlier)0ms ‣

        var later, orred;
        later = thatDay('09:30', '11:30');
        orred = later.xor(someTime);
        assertEqual(2, orred.length);
        assertTwixEqual(someTime, orred[0]);
        return assertTwixEqual(later, orred[1]);
      • returns the outside parts of a partially overlapping range (later)1ms ‣

        var orred;
        orred = someTime.xor(thatDay('08:00', '11:30'));
        assertEqual(2, orred.length);
        assertTwixEqual(thatDay('05:30', '08:00'), orred[0]);
        return assertTwixEqual(thatDay('08:30', '11:30'), orred[1]);
      • returns the outside parts of a partially overlapping range (earlier)0ms ‣

        var orred;
        orred = thatDay('08:00', '11:30').xor(someTime);
        assertEqual(2, orred.length);
        assertTwixEqual(thatDay('05:30', '08:00'), orred[0]);
        return assertTwixEqual(thatDay('08:30', '11:30'), orred[1]);
      • returns the outside parts when engulfing a range0ms ‣

        var orred;
        orred = someTime.xor(thatDay('06:30', '07:30'));
        assertEqual(2, orred.length);
        assertTwixEqual(thatDay('05:30', '06:30'), orred[0]);
        return assertTwixEqual(thatDay('07:30', '08:30'), orred[1]);
      • returns the outside parts of an engulfing range0ms ‣

        var orred;
        orred = thatDay('06:30', '07:30').xor(someTime);
        assertEqual(2, orred.length);
        assertTwixEqual(thatDay('05:30', '06:30'), orred[0]);
        return assertTwixEqual(thatDay('07:30', '08:30'), orred[1]);
      • returns one contiguous range for two adajacent ranges1ms ‣

        var orred;
        orred = thatDay('08:30', '10:30').xor(someTime);
        assertEqual(1, orred.length);
        return assertTwixEqual(thatDay('05:30', '10:30'), orred[0]);
    • one all-day range

      • uses the full day in the xor0ms ‣

        var xored;
        xored = someDays.xor(new Twix('1982-05-25T16:00', '1982-05-26T02:00'));
        assertEqual(2, xored.length);
        assertTwixEqual(new Twix('1982-05-24T00:00', '1982-05-25T16:00'), xored[0]);
        return assertTwixEqual(new Twix('1982-05-26T00:00', '1982-05-26T02:00'), xored[1]);
    • two all-day ranges

      • returns an all-day range0ms ‣

        var xored;
        xored = someDays.xor(new Twix('1982-05-25', '1982-05-27', true));
        assertEqual(2, xored.length);
        assertTwixEqual(new Twix('1982-05-24', '1982-05-24', true), xored[0]);
        return assertTwixEqual(new Twix('1982-05-26', '1982-05-27', true), xored[1]);
    • multiple ranges

      • returns the xor of three ranges0ms ‣

        var early, later, tween, xored;
        tween = thatDay('10:00', '13:00');
        early = thatDay('08:00', '11:00');
        later = thatDay('12:00', '14:00');
        xored = tween.xor(early, later);
        assertEqual(3, xored.length);
        assertTwixEqual(thatDay('08:00', '10:00'), xored[0]);
        assertTwixEqual(thatDay('11:00', '12:00'), xored[1]);
        return assertTwixEqual(thatDay('13:00', '14:00'), xored[2]);
  • difference()

    • non-all-day ranges

      • returns self for non-overlapping ranges (later)0ms ‣

        var exed, later;
        later = thatDay('09:30', '11:30');
        exed = someTime.difference(later);
        assertEqual(1, exed.length);
        return assertTwixEqual(someTime, exed[0]);
      • returns self for non-overlapping ranges (earlier)0ms ‣

        var exed, later;
        later = thatDay('09:30', '11:30');
        exed = later.difference(someTime);
        assertEqual(1, exed.length);
        return assertTwixEqual(later, exed[0]);
      • returns the non-overlapping part of a partially overlapping range (later)1ms ‣

        var exed;
        exed = someTime.difference(thatDay('08:00', '11:30'));
        assertEqual(1, exed.length);
        return assertTwixEqual(thatDay('05:30', '08:00'), exed[0]);
      • returns the outside parts of a partially overlapping range (earlier)0ms ‣

        var exed;
        exed = thatDay('08:00', '11:30').difference(someTime);
        assertEqual(1, exed.length);
        return assertTwixEqual(thatDay('08:30', '11:30'), exed[0]);
      • returns the outside parts when engulfing a range0ms ‣

        var exed;
        exed = someTime.difference(thatDay('06:30', '07:30'));
        assertEqual(2, exed.length);
        assertTwixEqual(thatDay('05:30', '06:30'), exed[0]);
        return assertTwixEqual(thatDay('07:30', '08:30'), exed[1]);
      • returns empty for an engulfing range1ms ‣

        var exed;
        exed = thatDay('06:30', '07:30').difference(someTime);
        return assertEqual(0, exed.length);
      • returns self for an adjacent range0ms ‣

        var exed;
        exed = someTime.difference(thatDay('08:30', '10:30'));
        assertEqual(1, exed.length);
        return assertTwixEqual(someTime, exed[0]);
      • returns self for an adjacent range (inverse)1ms ‣

        var exed, other;
        other = thatDay('08:30', '10:30');
        exed = other.difference(someTime);
        assertEqual(1, exed.length);
        return assertTwixEqual(other, exed[0]);
    • one all-day range

      • uses the full day0ms ‣

        var exed;
        exed = someDays.difference(new Twix('1982-05-25T16:00', '1982-05-26T02:00'));
        assertEqual(1, exed.length);
        return assertTwixEqual(new Twix('1982-05-24T00:00', '1982-05-25T16:00'), exed[0]);
    • two all-day ranges

      • returns an all-day range1ms ‣

        var exed;
        exed = someDays.difference(new Twix('1982-05-25', '1982-05-27', true));
        assertEqual(1, exed.length);
        return assertTwixEqual(new Twix('1982-05-24', '1982-05-24', true), exed[0]);
      • doesn't mutate its inputs0ms ‣

        var first, firstEnd, firstStart, second, secondEnd, secondStart;
        first = new Twix('1982-05-24', '1982-05-25', true);
        second = new Twix('1982-05-25', '1982-05-27', true);
        firstStart = first.start();
        firstEnd = first._displayEnd.clone();
        secondStart = second.start();
        secondEnd = second._displayEnd.clone();
        first.difference(second);
        assertMomentEqual(firstStart, first.start());
        assertMomentEqual(firstEnd, first._displayEnd);
        assertMomentEqual(secondStart, second.start());
        return assertMomentEqual(secondEnd, second._displayEnd);
    • multiple ranges

      • returns the difference of three ranges0ms ‣

        var early, exed, later, tween;
        tween = thatDay('10:00', '13:00');
        early = thatDay('08:00', '11:00');
        later = thatDay('12:00', '14:00');
        exed = tween.difference(early, later);
        assertEqual(1, exed.length);
        return assertTwixEqual(thatDay('11:00', '12:00'), exed[0]);
  • split()

    • using a duration

      • accepts a duration directly1ms ‣

        var splits;
        splits = thatDay('05:01', '07:30').split(moment.duration(1, 'hour'));
        return assertHours(splits);
      • accepts number, unit as args0ms ‣

        var splits;
        splits = thatDay('05:01', '07:30').split(1, 'h');
        return assertHours(splits);
      • accepts an object1ms ‣

        var splits;
        splits = thatDay('05:01', '07:30').split(moment.duration({
          'h': 1
        }));
        return assertHours(splits);
      • returns the original if the duration is empty1ms ‣

        var range, splits;
        range = thatDay('05:01', '07:30');
        splits = range.split(moment.duration({
          'h': 0
        }));
        assertEqual(1, splits.length);
        return assertTwixEqual(range, splits[0]);
      • splits up all-day ranges into hours across the whole day1ms ‣

        var splits;
        splits = moment('1982-05-25').twix('1982-05-26', {
          allDay: true
        }).split(moment.duration(1, 'hour'));
        assertEqual(48, splits.length);
        assertTwixEqual(thatDay('00:00', '01:00'), splits[0]);
        return assertTwixEqual(moment.twix('1982-05-26T23:00', '1982-05-27T00:00'), splits[47]);
    • using times

      • accepts a single time0ms ‣

        var splits;
        splits = thatDay('05:00', '06:00').split('1982-05-25T05:30');
        assertEqual(2, splits.length);
        assertTwixEqual(thatDay('05:00', '05:30'), splits[0]);
        return assertTwixEqual(thatDay('05:30', '06:00'), splits[1]);
      • accepts multiple times1ms ‣

        var splits;
        splits = thatDay('05:00', '06:00').split('1982-05-25T05:30', '1982-05-25T05:45');
        assertEqual(3, splits.length);
        assertTwixEqual(thatDay('05:00', '05:30'), splits[0]);
        assertTwixEqual(thatDay('05:30', '05:45'), splits[1]);
        return assertTwixEqual(thatDay('05:45', '06:00'), splits[2]);
      • accepts a list of times1ms ‣

        var splits;
        splits = thatDay('05:00', '06:00').split(['1982-05-25T05:30', '1982-05-25T05:45']);
        assertEqual(3, splits.length);
        assertTwixEqual(thatDay('05:00', '05:30'), splits[0]);
        assertTwixEqual(thatDay('05:30', '05:45'), splits[1]);
        return assertTwixEqual(thatDay('05:45', '06:00'), splits[2]);
      • returns the original if there are no args0ms ‣

        var range, splits;
        range = thatDay('05:01', '07:30');
        splits = range.split();
        assertEqual(1, splits.length);
        return assertTwixEqual(range, splits[0]);
      • returns the original if the arg is an empty list0ms ‣

        var range, splits;
        range = thatDay('05:01', '07:30');
        splits = range.split([]);
        assertEqual(1, splits.length);
        return assertTwixEqual(range, splits[0]);
      • excludes bad times1ms ‣

        var splits;
        splits = thatDay('05:00', '06:00').split('1982-05-23', '1982-05-25T05:30', moment.invalid());
        assertEqual(2, splits.length);
        assertTwixEqual(thatDay('05:00', '05:30'), splits[0]);
        return assertTwixEqual(thatDay('05:30', '06:00'), splits[1]);
      • returns the original if they're all bad times0ms ‣

        var range, splits;
        range = thatDay('05:01', '07:30');
        splits = range.split(moment.invalid());
        assertEqual(1, splits.length);
        return assertTwixEqual(range, splits[0]);
      • splits at all provided times0ms ‣

        var splits;
        splits = moment.twix('2016-11-16T16:00:00', '2016-11-17T00:00:00').split('2016-11-16T18:00:00', '2016-11-17T00:00:00');
        assertEqual(2, splits.length);
        assertTwixEqual(moment.twix('2016-11-16T16:00:00', '2016-11-16T18:00:00'), splits[0]);
        return assertTwixEqual(moment.twix('2016-11-16T18:00:00', '2016-11-17T00:00:00'), splits[1]);
  • divide()

    • should split a 4 hour period into 4 contiguous 1-hour parts1ms ‣

      var range, splits;
      range = thatDay('05:00', '09:00');
      splits = range.divide(4);
      assertEqual(4, splits.length);
      return assertTwixEqual(thatDay('06:00', '07:00'), splits[1]);
    • should split a 1m30s into 3 30-second parts1ms ‣

      var range, splits;
      range = thatDay('05:00:00', '05:01:30');
      splits = range.divide(3);
      assertEqual(3, splits.length);
      return assertTwixEqual(thatDay('05:01:00', '05:01:30'), splits[2]);
    • always gives you the right number of parts1ms ‣

      var range, splits;
      range = thatDay('05:00:00', '05:01:30');
      splits = range.divide(17);
      return assertEqual(17, splits.length);
  • isValid()

    • should return false when the start time is invalid0ms ‣

      return assertEqual(false, new Twix('1980-13-45', '1982-05-26').isValid());
    • should return false when the end time is invalid0ms ‣

      return assertEqual(false, new Twix('1982-05-25', '1985-13-45').isValid());
    • should validate an interval with an earlier start1ms ‣

      assertEqual(true, new Twix('1982-05-24', '1982-05-26').isValid());
      assertEqual(true, new Twix('1982-05-24', '1982-05-26', true).isValid());
      assertEqual(true, new Twix('1982-05-24 20:00', '1982-05-26 07:00').isValid());
      return assertEqual(true, new Twix('1982-05-24 20:00', '1982-05-26 07:00', true).isValid());
    • should validate an interval without range0ms ‣

      assertEqual(true, new Twix('1982-05-24', '1982-05-24').isValid());
      assertEqual(true, new Twix('1982-05-24', '1982-05-24', true).isValid());
      assertEqual(true, new Twix('1982-05-24 20:00', '1982-05-24 20:00').isValid());
      return assertEqual(true, new Twix('1982-05-24 20:00', '1982-05-24 20:00', true).isValid());
    • should not validate an interval with a later start0ms ‣

      assertEqual(false, new Twix('1982-05-26', '1982-05-24').isValid());
      assertEqual(false, new Twix('1982-05-26', '1982-05-24', true).isValid());
      assertEqual(false, new Twix('1982-05-26 07:00', '1982-05-24 20:00').isValid());
      return assertEqual(false, new Twix('1982-05-26 07:00', '1982-05-24 20:00', true).isValid());
    • should validate a same day interval with a later start0ms ‣

      return assertEqual(true, new Twix('1982-05-24 20:00', '1982-05-24 00:00', true).isValid());
  • simpleFormat()

    • provides a simple string when provided no options1ms ‣

      var s;
      s = yesterday().twix(tomorrow()).simpleFormat();
      return assertEqual(true, s.indexOf(' - ') > -1);
    • specifies '(all day)' if it's all day0ms ‣

      var s;
      s = yesterday().twix(tomorrow(), true).simpleFormat();
      return assertEqual(true, s.indexOf('(all day)') > -1);
    • accepts moment formatting options0ms ‣

      var s;
      s = thisYear('10-14').twix(thisYear('10-14')).simpleFormat('MMMM');
      return assertEqual('October - October', s);
    • accepts an allDay option0ms ‣

      var s;
      s = thisYear('05-25').twix(thisYear('05-26'), true).simpleFormat(null, {
        allDay: '(wayo wayo)'
      });
      return assertEqual(true, s.indexOf('(wayo wayo)') > -1);
    • removes the all day text if allDay is null0ms ‣

      var s;
      s = thisYear('05-25').twix(thisYear('05-26'), true).simpleFormat(null, {
        allDay: null
      });
      return assertEqual(true, s.indexOf('(all day)') === -1);
    • accepts a custom template1ms ‣

      var s;
      s = thisYear('05-25').twix(thisYear('05-26'), true).simpleFormat(null, {
        template: function(first, second) {
          return first + " | " + second;
        }
      });
      return assertEqual(true, s.indexOf('|') > -1);
  • format()

    • simple ranges

      • empty range1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • different year, different day shows everything1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • this year, different day skips year0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • this year, different day shows year if requested0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • same day, different times shows date once0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • same day, different times, same meridian shows date and meridiem once0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • custom month format for regular range0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • custom month format for all day range0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • rounded times

      • round hour doesn't show :000ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • mixed times still shows :300ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • implicit minutes

      • still shows the :000ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • all day ranges

      • one day has no range1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • same month says month on one side0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • same month says month on one side, with year if requested1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • different month shows both0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • different month shows both, with year if requested1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • explicit year shows the year once0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • different year shows the year twice1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • different year different month shows the month at the end0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • explicit allDay1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • hidden times

      • hide times if requested0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • hide times even for a single day0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • implicit dates

      • should show dates for non-today dates0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • shouldn't show the dates running into early tomorrow0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • shouldn't show dates for today0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • should show the dates for multiday0ms ‣

        var end, range, start;
        start = todayAt(6, 30);
        end = tomorrowAt(4, 45);
        range = start.twix(end);
        return assertEqual(range.format({
          implicitDate: true
        }), range.format());
      • should just say 'all day' for all day ranges1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • hidden dates

      • should hide dates0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • should hide dates even if multiday0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • hidden years

      • differs to implicitYear by default0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • hides year if requested0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • hides year even if multiyear0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • ungroup meridiems

      • should put meridiems on both sides0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • even with abbreviated hours0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • no meridiem spaces

      • should skip the meridiem space0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • hour format

      • can override to 2-digit hours1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • can override to 24-hour time0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • show day of week

      • should show day of week0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • should show day of week, specify day of week format1ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • collapses show day of week0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • doesn't collapse with one week of separation0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
    • goes into the morning

      • elides late nights0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • keeps late mornings0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • morning start is adjustable0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • doesn't elide if you start in the AM0ms ‣

        var twix;
        twix = new Twix(t.start, t.end, t.allDay);
        return assertEqual(t.result, twix.format(t.options));
      • and we're trying to hide the date

        • doesn't elide if the morning ends late0ms ‣

          var twix;
          twix = new Twix(t.start, t.end, t.allDay);
          return assertEqual(t.result, twix.format(t.options));
      • other options

        • accepts a custom format0ms ‣

          return {
            start: '1982-05-25 17:00',
            end: '1982-05-26 10:00',
            options: {
              template: function(first, second) {
                return first + " | " + second;
              }
            },
            result: 'May 25, 5 PM | May 26, 10 AM, 1982'
          };
  • toString

    • returns a string1ms ‣

      var stringed;
      stringed = moment.utc('1982-05-25').twix(moment.utc('1982-05-25'), {
        allDay: true
      }).toString();
      return assertEqual('{start: 1982-05-25T00:00:00Z, end: 1982-05-25T00:00:00Z, allDay: true}', stringed);
  • toArray

    • returns an array of moment objects0ms ‣

      var arrayOfDays;
      arrayOfDays = moment.utc('1982-05-25').twix(moment.utc('1982-05-27'), {
        allDay: true
      }).toArray('days').map(function(m) {
        return m.format('YYYY-MM-DD');
      });
      return assertArrayEqual(['1982-05-25', '1982-05-26', '1982-05-27'], arrayOfDays);
  • internationalization

    • shows the date in the right order0ms ‣

      var range, start;
      start = moment('1982-05-25').locale('en-gb');
      range = start.twix(start.clone().add(1, 'hour'));
      return assertEqual('25 May 1982, 0:00 - 1:00', range.format());
    • shows the date in the right order for all day ranges0ms ‣

      var range, start;
      start = moment('1982-05-25').locale('en-gb');
      range = start.twix(start.clone().add(1, 'days'), {
        allDay: true
      });
      return assertEqual('25 - 26 May 1982', range.format());
    • uses the moment locale's 24-hour setting1ms ‣

      var range, start;
      start = moment('1982-05-25').locale('en-gb');
      range = start.twix(start.clone().add(1, 'days'));
      return assertEqual('25 May, 0:00 - 26 May, 0:00 1982', range.format());
    • uses the moment locale's month names0ms ‣

      var range, start;
      start = moment('1982-05-25').locale('fr');
      range = start.twix(start.clone().add(1, 'days'));
      return assertEqual('25 mai, 0:00 - 26 mai, 0:00 1982', range.format());