/** split the schedule at a given date.
*/
protected void splitAt(Date effDate) {
// find the period that contains the given date.
Period r = get(effDate);
int pos = periods.indexOf(r);
// if the date already begins or ends with the given date, we
// don't need to do anything.
if (r.endDate.equals(effDate) || r.getBeginDate().equals(effDate))
return;
// calculate what percentage of the period lies on each side
// of the given date.
long eff = effDate.getTime();
long start = r.getBeginDate().getTime();
long end = r.endDate.getTime();
double duration = end - start;
double left = (eff - start) / duration;
double right = (end - eff) / duration;
// create a new period that ends on the given date; insert it
// before the existing period; adjust "previous" pointers
Period l = new Period(effDate, 0.0);
l.previous = r.previous;
r.previous = l;
periods.add(pos, l);
// proportionally distribute plan total time