void tidy(int windowStartYear){
  if (lastRuleList.size() == 1) {
    throw new IllegalStateException("Cannot have only one rule defined as being forever");
  }
  if (windowEnd.equals(LocalDateTime.MAX)) {
    maxLastRuleStartYear=Math.max(maxLastRuleStartYear,windowStartYear) + 1;
    for (    TZRule lastRule : lastRuleList) {
      addRule(lastRule.year,maxLastRuleStartYear,lastRule.month,lastRule.dayOfMonthIndicator,lastRule.dayOfWeek,lastRule.time,lastRule.timeEndOfDay,lastRule.timeDefinition,lastRule.savingAmountSecs);
      lastRule.year=maxLastRuleStartYear + 1;
    }
    if (maxLastRuleStartYear == YEAR_MAX_VALUE) {
      lastRuleList.clear();
    }
 else {
      maxLastRuleStartYear++;
    }
  }
 else {
    int endYear=windowEnd.getYear();
    for (    TZRule lastRule : lastRuleList) {
      addRule(lastRule.year,endYear + 1,lastRule.month,lastRule.dayOfMonthIndicator,lastRule.dayOfWeek,lastRule.time,lastRule.timeEndOfDay,lastRule.timeDefinition,lastRule.savingAmountSecs);
    }
    lastRuleList.clear();
    maxLastRuleStartYear=YEAR_MAX_VALUE;
  }
  Collections.sort(ruleList);
  Collections.sort(lastRuleList);
  if (ruleList.size() == 0 && fixedSavingAmountSecs == null) {
    fixedSavingAmountSecs=0;
  }
}

void tidy ( int windowStartYear ) { if ( lastRuleList . size ( ) == 1 ) { throw new IllegalStateException ( "Cannot have only one rule defined as being forever" ) ; } if ( windowEnd . equals ( LocalDateTime . MAX ) ) { maxLastRuleStartYear = Math . max ( maxLastRuleStartYear , windowStartYear ) + 1 ; for ( TZRule lastRule : lastRuleList ) { addRule ( lastRule . year , maxLastRuleStartYear , lastRule . month , lastRule . dayOfMonthIndicator , lastRule . dayOfWeek , lastRule . time , lastRule . timeEndOfDay , lastRule . timeDefinition , lastRule . savingAmountSecs ) ; lastRule . year = maxLastRuleStartYear + 1 ; } if ( maxLastRuleStartYear == YEAR_MAX_VALUE ) { lastRuleList . clear ( ) ; } else { maxLastRuleStartYear ++ ; } } else { int endYear = windowEnd . getYear ( ) ; for ( TZRule lastRule : lastRuleList ) { addRule ( lastRule . year , endYear + 1 , lastRule . month , lastRule . dayOfMonthIndicator , lastRule . dayOfWeek , lastRule . time , lastRule . timeEndOfDay , lastRule . timeDefinition , lastRule . savingAmountSecs ) ; } lastRuleList . clear ( ) ; maxLastRuleStartYear = YEAR_MAX_VALUE ; } Collections . sort ( ruleList ) ; Collections . sort ( lastRuleList ) ; if ( ruleList . size ( ) == 0 && fixedSavingAmountSecs == null ) { fixedSavingAmountSecs = 0 ; } }
adds rules to make the last rules all start from the same year . also add one more year to avoid weird case where penultimate year has odd offset .
