// insert a new range starting at the given date extending to the end of the zone currently // containing that date. If the start date of that zone is prior to the specified start // date, then that zone range is shorted. int Zones::insertRangeAtDate(QDate date, int cp) { assert(date.isValid()); int rnum; if (ranges.empty()) { addZoneRange(); rnum = 0; } else { rnum = whichRange(date); assert(rnum >= 0); QDate date1 = getStartDate(rnum); // if the old range has dates before the specified, then truncate // the old range and shift up the existing ranges if (date > date1) { QDate endDate = getEndDate(rnum); setEndDate(rnum, date); ranges.insert(++ rnum, ZoneRange(date, endDate)); } } if (cp > 0) { setCP(rnum, cp); setZonesFromCP(rnum); } return rnum; }
// insert a new range starting at the given date extending to the end of the zone currently // containing that date. If the start date of that zone is prior to the specified start // date, then that zone range is shorted. int Zones::insertRangeAtDate(QDate date, int cp) { assert(date.isValid()); int rnum; if (ranges.empty()) { addZoneRange(cp); fprintf( stderr, "Generating first range with CP = %d\n", cp ); rnum = 0; } else { rnum = whichRange(date); assert(rnum >= 0); QDate date1 = getStartDate(rnum); fprintf(stderr, "insertRangeAtDate(%s, %d):\n", date.toString().toAscii().constData(), cp); // if the old range has dates before the specified, then truncate the old range // and shift up the existing ranges if (date > date1) { QDate endDate = getEndDate(rnum); setEndDate(rnum, date); fprintf( stderr, "Inserting range\n" "old range %d: from %s to %s\n" "new range %d: from %s to %s\n" "added range %d: from %s to %s\n", rnum + 1, getStartDateString(rnum).toAscii().constData(), getEndDateString(rnum).toAscii().constData(), rnum + 1, getStartDateString(rnum).toAscii().constData(), (date.isNull() ? "END" : date.toString().toAscii().constData()), rnum + 2, (date.isNull() ? "BEGIN" : date.toString().toAscii().constData()), getEndDateString(rnum).toAscii().constData() ); ranges.insert(++ rnum, new ZoneRange(date, endDate)); } } if (cp > 0) { setCP(rnum, cp); setZonesFromCP(rnum); } return rnum; }