private String fromCalendar(boolean withBrackets) { StringBuilder result = new StringBuilder(); if (withBrackets) { result.append(isActive() ? '<' : '['); } result.append(DATE_FORMAT.format(cal.getTime())); if (hasTime) { result.append(" "); result.append(TIME_FORMAT.format(cal.getTime())); if (endCal != null) { result.append("-"); result.append(TIME_FORMAT.format(endCal.getTime())); } } if (hasRepeater()) { result.append(" "); result.append(repeater); } if (hasDelay()) { result.append(" "); result.append(delay); } if (withBrackets) { result.append(isActive() ? '>' : ']'); } return result.toString(); }
public boolean shift(Calendar now) { /* * Calling the method below will also make sure * that string is parsed and calendars are updated. */ if (hasRepeater()) { cal = getCalendar(); endCal = getEndCalendar(); /* Shift both calendars. */ repeater.shiftCalendar(cal, now); if (endCal != null) { repeater.shiftCalendar(endCal, now); } /* Invalidate string representations. */ string = null; stringWithoutBrackets = null; } return repeater != null; }
if (!useRepeater || !orgDateTime.hasRepeater() || orgDateTime.getRepeater().getValue() == 0) { if (!time.isBefore(fromTime) && (beforeTime == null || time.isBefore(beforeTime))) { result.add(time);
@Test public void testDelayOnlyWithTime() { OrgDateTime time = OrgDateTime.parse("<2009-10-17 13:15 -2d>"); Assert.assertFalse(time.hasRepeater()); Assert.assertTrue(time.hasDelay()); Assert.assertEquals(OrgDelay.Type.ALL, time.getDelay().getType()); Assert.assertEquals(2, time.getDelay().getValue()); Assert.assertEquals(OrgDelay.Unit.DAY, time.getDelay().getUnit()); }
@Test public void testDelayOnlyWithWeekday() { OrgDateTime time = OrgDateTime.parse("<2009-10-17 Wed -2d>"); Assert.assertFalse(time.hasRepeater()); Assert.assertTrue(time.hasDelay()); Assert.assertEquals(OrgDelay.Type.ALL, time.getDelay().getType()); Assert.assertEquals(2, time.getDelay().getValue()); Assert.assertEquals(OrgDelay.Unit.DAY, time.getDelay().getUnit()); }
@Test public void testDelayFirstOccurrence() { OrgDateTime time = OrgDateTime.parse("<2009-10-17 13:15 +1m --2d>"); Assert.assertTrue(time.hasRepeater()); Assert.assertTrue(time.hasDelay()); Assert.assertEquals(OrgDelay.Type.FIRST_ONLY, time.getDelay().getType()); Assert.assertEquals(2, time.getDelay().getValue()); Assert.assertEquals(OrgDelay.Unit.DAY, time.getDelay().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()); }