Package er.chronic.utils

Examples of er.chronic.utils.Span


      t = parse_now("in 3 hrs");
      assertEquals(Time.construct(2006, 8,16,17), t);
    }

    public void test_fractional_times() {
      Span t = parse_now("in three and a half hours");
      assertEquals(Time.construct(2006, 8,16,17, 30), t);

      t = parse_now("in 3.5 hours");
      assertEquals(Time.construct(2006, 8,16,17, 30), t);
    }
View Full Code Here


    super.setUp();
    _now = Time.construct(2006, 8, 16, 14, 0, 0, 0);
  }

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

    Span offsetSpan;
    offsetSpan = new RepeaterMonth().getOffset(span, 1, Pointer.PointerType.FUTURE);

    assertEquals(Time.construct(2006, 9, 16, 14), offsetSpan.getBeginCalendar());
    assertEquals(Time.construct(2006, 9, 16, 14, 1), offsetSpan.getEndCalendar());

    offsetSpan = new RepeaterMonth().getOffset(span, 1, Pointer.PointerType.PAST);

    assertEquals(Time.construct(2006, 7, 16, 14), offsetSpan.getBeginCalendar());
    assertEquals(Time.construct(2006, 7, 16, 14, 1), offsetSpan.getEndCalendar());
  }
View Full Code Here

  public void testNext() {
    RepeaterMonthName mays = new RepeaterMonthName(RepeaterMonthName.MonthName.MAY);
    mays.setStart(_now);
   
    Span nextMay = mays.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2007, 5), nextMay.getBeginCalendar());
    assertEquals(Time.construct(2007, 6), nextMay.getEndCalendar());

    Span nextNextMay = mays.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2008, 5), nextNextMay.getBeginCalendar());
    assertEquals(Time.construct(2008, 6), nextNextMay.getEndCalendar());

    RepeaterMonthName decembers = new RepeaterMonthName(RepeaterMonthName.MonthName.DECEMBER);
    decembers.setStart(_now);
   
    Span nextDecember = decembers.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 12), nextDecember.getBeginCalendar());
    assertEquals(Time.construct(2007, 1), nextDecember.getEndCalendar());

    mays = new RepeaterMonthName(RepeaterMonthName.MonthName.MAY);
    mays.setStart(_now);
   
    assertEquals(Time.construct(2006, 5), mays.nextSpan(Pointer.PointerType.PAST).getBeginCalendar());
View Full Code Here

  public void testThis() {
    RepeaterMonthName octobers = new RepeaterMonthName(RepeaterMonthName.MonthName.MAY);
    octobers.setStart(_now);
   
    Span nextMay = octobers.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2007, 5), nextMay.getBeginCalendar());
    assertEquals(Time.construct(2007, 6), nextMay.getEndCalendar());

    Span nextNextMay = octobers.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2008, 5), nextNextMay.getBeginCalendar());
    assertEquals(Time.construct(2008, 6), nextNextMay.getEndCalendar());
  }
View Full Code Here

    repeater = RepeaterDayName.scan(token);
    assertEquals(RepeaterDayName.DayName.SUNDAY, repeater.getType());
  }

  public void testNextFuture() {
    Span span;
   
    RepeaterDayName mondays = new RepeaterDayName(RepeaterDayName.DayName.MONDAY);
    mondays.setStart(_now);
    span = mondays.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 21), span.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 22), span.getEndCalendar());

    span = mondays.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 28), span.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 29), span.getEndCalendar());
  }
View Full Code Here

    assertEquals(Time.construct(2006, 8, 28), span.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 29), span.getEndCalendar());
  }

  public void testNextPast() {
    Span span;
   
    RepeaterDayName mondays = new RepeaterDayName(RepeaterDayName.DayName.MONDAY);
    mondays.setStart(_now);
    span = mondays.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 14), span.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 15), span.getEndCalendar());

    span = mondays.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 7), span.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 8), span.getEndCalendar());
  }
View Full Code Here

import er.chronic.utils.Time;

public class SpanTest extends TestCase {

  public void testSpanWidth() {
    Span span = new Span(Time.construct(2006, 8, 16, 0), Time.construct(2006, 8, 17, 0));
    assertEquals(60 * 60 * 24, span.getWidth());
  }
View Full Code Here

    Span span = new Span(Time.construct(2006, 8, 16, 0), Time.construct(2006, 8, 17, 0));
    assertEquals(60 * 60 * 24, span.getWidth());
  }

  public void testSpanMath() {
    Span span = new Span(1, 2);
    assertEquals(2, span.add(1).getBegin());
    assertEquals(3, span.add(1).getEnd());
    assertEquals(0, span.subtract(1).getBegin());
    assertEquals(1, span.subtract(1).getEnd());
  }
View Full Code Here

  }

  public void testNextPast() {
    RepeaterWeekend weekends = new RepeaterWeekend();
    weekends.setStart(_now);
    Span lastWeekend = weekends.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 12), lastWeekend.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 14), lastWeekend.getEndCalendar());
  }
View Full Code Here

  public void testThisFuture() {
    RepeaterWeekend weekends = new RepeaterWeekend();
    weekends.setStart(_now);

    Span thisWeekend = weekends.thisSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 19), thisWeekend.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 21), thisWeekend.getEndCalendar());
  }
View Full Code Here

TOP

Related Classes of er.chronic.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.