Package com.mdimension.jchronic.utils

Examples of com.mdimension.jchronic.utils.Span


    assertEquals(RepeaterDayPortion.DayPortion.MORNING, tokens.get(1).getTags().get(0).getType());
    assertEquals(2, tokens.size());
  }

  public void testGuess() {
    Span span;

    span = new Span(Time.construct(2006, 8, 16, 0), Time.construct(2006, 8, 17, 0));
    assertEquals(Time.construct(2006, 8, 16, 12), Chronic.guess(span).getBeginCalendar());

    span = new Span(Time.construct(2006, 8, 16, 0), Time.construct(2006, 8, 17, 0, 0, 1));
    assertEquals(Time.construct(2006, 8, 16, 12), Chronic.guess(span).getBeginCalendar());

    span = new Span(Time.construct(2006, 11), Time.construct(2006, 12));
    assertEquals(Time.construct(2006, 11, 16), Chronic.guess(span).getBeginCalendar());
  }
View Full Code Here


    }
    else {
      _currentMonthStart = Time.cloneAndAdd(_currentMonthStart, Calendar.MONTH, direction);
    }

    return new Span(_currentMonthStart, Calendar.MONTH, 1);
  }
View Full Code Here

  }

  @Override
  public Span getOffset(Span span, int amount, Pointer.PointerType pointer) {
    int direction = (pointer == Pointer.PointerType.FUTURE) ? 1 : -1;
    return new Span(Time.cloneAndAdd(span.getBeginCalendar(), Calendar.MONTH, amount * direction), Time.cloneAndAdd(span.getEndCalendar(), Calendar.MONTH, amount * direction));
  }
View Full Code Here

      monthEnd = Time.cloneAndAdd(Time.ym(getNow()), Calendar.MONTH, 1);
    }
    else {
      throw new IllegalArgumentException("Unable to handle pointer " + pointer + ".");
    }
    return new Span(monthStart, monthEnd);
  }
View Full Code Here

  public void testNextFuture() {
    RepeaterFortnight fortnights = new RepeaterFortnight();
    fortnights.setStart(_now);

    Span nextFortnight = fortnights.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 20), nextFortnight.getBeginCalendar());
    assertEquals(Time.construct(2006, 9, 3), nextFortnight.getEndCalendar());

    Span nextNextFortnight = fortnights.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 9, 3), nextNextFortnight.getBeginCalendar());
    assertEquals(Time.construct(2006, 9, 17), nextNextFortnight.getEndCalendar());
  }
View Full Code Here

  }

  public void testNextPast() {
    RepeaterFortnight fortnights = new RepeaterFortnight();
    fortnights.setStart(_now);
    Span lastFortnight = fortnights.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 7, 30), lastFortnight.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 13), lastFortnight.getEndCalendar());

    Span lastLastFortnight = fortnights.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 7, 16), lastLastFortnight.getBeginCalendar());
    assertEquals(Time.construct(2006, 7, 30), lastLastFortnight.getEndCalendar());
  }
View Full Code Here

  public void testThisFuture() {
    RepeaterFortnight fortnights = new RepeaterFortnight();
    fortnights.setStart(_now);

    Span thisFortnight = fortnights.thisSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 16, 15), thisFortnight.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 27), thisFortnight.getEndCalendar());
  }
View Full Code Here

  public void testThisPast() {
    RepeaterFortnight fortnights = new RepeaterFortnight();
    fortnights.setStart(_now);

    Span thisFortnight = fortnights.thisSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 13, 0), thisFortnight.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 14), thisFortnight.getEndCalendar());
  }
View Full Code Here

    assertEquals(Time.construct(2006, 8, 13, 0), thisFortnight.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 14), thisFortnight.getEndCalendar());
  }

  public void testOffset() {
      Span span = new Span(_now, Calendar.SECOND, 1);

      Span offsetSpan = new RepeaterWeek().getOffset(span, 3, Pointer.PointerType.FUTURE);

      assertEquals(Time.construct(2006, 9, 6, 14), offsetSpan.getBeginCalendar());
      assertEquals(Time.construct(2006, 9, 6, 14, 0, 1), offsetSpan.getEndCalendar());
  }
View Full Code Here

  public void testNextFuture() {
    RepeaterHour hours = new RepeaterHour();
    hours.setStart(_now);

    Span nextHour = hours.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 16, 15), nextHour.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 16), nextHour.getEndCalendar());

    Span nextNextHour = hours.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 16, 16), nextNextHour.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 17), nextNextHour.getEndCalendar());
  }
View Full Code Here

TOP

Related Classes of com.mdimension.jchronic.utils.Span

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.