private void shiftByInterval(Calendar cal) { switch (getUnit()) { case HOUR: cal.add(Calendar.HOUR_OF_DAY, getValue()); break; case DAY: cal.add(Calendar.DATE, getValue()); break; case WEEK: cal.add(Calendar.WEEK_OF_YEAR, getValue()); break; case MONTH: cal.add(Calendar.MONTH, getValue()); break; case YEAR: cal.add(Calendar.YEAR, getValue()); break; } }
if (!useRepeater || !orgDateTime.hasRepeater() || orgDateTime.getRepeater().getValue() == 0) { if (!time.isBefore(fromTime) && (beforeTime == null || time.isBefore(beforeTime))) { result.add(time); int repeatTimes = units / repeater.getValue(); int addUnits = repeater.getValue() * (repeatTimes + 1); repeater.getValue() );
@Test public void testRepeaterEvery() { OrgDateTime time = OrgDateTime.parse("<2014-05-26 +4w>"); Assert.assertEquals(4, time.getRepeater().getValue()); Assert.assertEquals(OrgRepeater.Type.CUMULATE, time.getRepeater().getType()); Assert.assertEquals(OrgRepeater.Unit.WEEK, time.getRepeater().getUnit()); }
@Test public void testRepeaterInFuture() { OrgDateTime time = OrgDateTime.parse("<2014-05-26 ++4w>"); Assert.assertEquals(4, time.getRepeater().getValue()); Assert.assertEquals(OrgRepeater.Type.CATCH_UP, time.getRepeater().getType()); Assert.assertEquals(OrgRepeater.Unit.WEEK, time.getRepeater().getUnit()); }
@Test public void testRepeaterInAfterToday() { OrgDateTime time = OrgDateTime.parse("<2014-05-26 .+4w>"); Assert.assertEquals(4, time.getRepeater().getValue()); Assert.assertEquals(OrgRepeater.Type.RESTART, time.getRepeater().getType()); Assert.assertEquals(OrgRepeater.Unit.WEEK, time.getRepeater().getUnit()); }
@Test public void testRepeaterWithoutWeekDay() { OrgDateTime time = OrgDateTime.parse("<2009-10-17 13:15 .+2d/4d>"); Assert.assertTrue(time.isActive()); Assert.assertTrue(time.hasTime()); Assert.assertTrue(time.hasRepeater()); Assert.assertEquals(2, time.getRepeater().getValue()); Assert.assertEquals(OrgRepeater.Type.RESTART, time.getRepeater().getType()); Assert.assertEquals(OrgRepeater.Unit.DAY, time.getRepeater().getUnit()); Assert.assertTrue(time.getRepeater().hasHabitDeadline()); }
@Test public void testRepeaterWithHabitDeadline() { OrgDateTime time = OrgDateTime.parse("<2009-10-17 Sat 13:15 .+2d/4d>"); Assert.assertTrue(time.isActive()); Assert.assertTrue(time.hasTime()); Assert.assertEquals(13, time.getCalendar().get(Calendar.HOUR_OF_DAY)); Assert.assertTrue(time.hasRepeater()); Assert.assertEquals(2, time.getRepeater().getValue()); Assert.assertEquals(OrgRepeater.Type.RESTART, time.getRepeater().getType()); Assert.assertEquals(OrgRepeater.Unit.DAY, time.getRepeater().getUnit()); Assert.assertTrue(time.getRepeater().hasHabitDeadline()); Assert.assertEquals(OrgRepeater.Unit.DAY, time.getRepeater().getHabitDeadline().getUnit()); Assert.assertEquals(4, time.getRepeater().getHabitDeadline().getValue()); }