109 110 Arrays.sort(recs, new Comparator<RuleRec>() { 111 public int compare(RuleRec r1, RuleRec r2) { 112 int n = r1.getMonthNum() - r2.getMonthNum(); 113 if (n != 0) { 114 return n; 115 } 116 // TODO: it's not accurate to ignore time types (STD, WALL, UTC) 117 long t1 = Time.getLocalTime(y, r1.getMonth(), 118 r1.getDay(), r1.getTime().getTime()); 119 long t2 = Time.getLocalTime(y, r2.getMonth(), 120 r2.getDay(), r2.getTime().getTime()); 121 return Long.compare(t1, t2); 122 } 123 public boolean equals(Object o) { 124 return this == o; 125 } 126 }); 127 rules.clear(); 128 for (int i = 0; i < n; i++) { 129 rules.add(recs[i]); 130 } 131 return rules; 132 } 133 134 /** 135 * Gets rule records that have either "max" or cover the endYear 136 * value in its DST schedule. 137 * 138 * @return rules that contain last DST schedule. An empty 139 * ArrayList is returned if no last rules are found. 140 */ 141 List<RuleRec> getLastRules() { 142 RuleRec start = null; 143 RuleRec end = null; 144 145 for (int i = 0; i < list.size(); i++) { 146 RuleRec rec = list.get(i); 147 if (rec.isLastRule()) { 148 if (rec.getSave() > 0) { | 109 110 Arrays.sort(recs, new Comparator<RuleRec>() { 111 public int compare(RuleRec r1, RuleRec r2) { 112 int n = r1.getMonthNum() - r2.getMonthNum(); 113 if (n != 0) { 114 return n; 115 } 116 // TODO: it's not accurate to ignore time types (STD, WALL, UTC) 117 long t1 = Time.getLocalTime(y, r1.getMonth(), 118 r1.getDay(), r1.getTime().getTime()); 119 long t2 = Time.getLocalTime(y, r2.getMonth(), 120 r2.getDay(), r2.getTime().getTime()); 121 return Long.compare(t1, t2); 122 } 123 public boolean equals(Object o) { 124 return this == o; 125 } 126 }); 127 rules.clear(); 128 for (int i = 0; i < n; i++) { 129 130 if (i != 0 && recs[i -1].getSave() == recs[i].getSave()) { 131 // we have two recs back to back with same saving for the same year. 132 if (recs[i].isLastRule()) { 133 continue; 134 } else if (recs[i - 1].isLastRule()) { 135 rules.remove(rules.size() - 1); 136 } 137 } 138 rules.add(recs[i]); 139 } 140 return rules; 141 } 142 143 /** 144 * Gets rule records that have either "max" or cover the endYear 145 * value in its DST schedule. 146 * 147 * @return rules that contain last DST schedule. An empty 148 * ArrayList is returned if no last rules are found. 149 */ 150 List<RuleRec> getLastRules() { 151 RuleRec start = null; 152 RuleRec end = null; 153 154 for (int i = 0; i < list.size(); i++) { 155 RuleRec rec = list.get(i); 156 if (rec.isLastRule()) { 157 if (rec.getSave() > 0) { |