Changeset 1215
- Timestamp:
- 11/02/06 07:00:11 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/config/AgaviTimeZoneDataParser.class.php
r1210 r1215 136 136 137 137 $this->prepareRules($rules); 138 foreach($this->rules as $name => $rule) { 139 echo "rule $name:\n"; 140 foreach($rule['rules'] as $r) { 141 echo " rule ($r[time] ".implode(',', array_keys($r))."): " . gmdate("d.m.Y H:i:s", $r['time']) . "\n"; 142 } 143 echo "\n"; 144 } 138 145 $zones = $this->generateDatatables($zones); 139 146 … … 148 155 $activeRules = array(); 149 156 $myRules = array(); 157 158 $lastDstOff = 0; 150 159 151 160 $cnt = count($ruleList); … … 165 174 do { 166 175 $needsBreak = false; 176 177 $hasNonFinalRules = false; 178 // check if we have any active rules which are not final, so we need to process the final ones too 179 foreach($activeRules as $activeRule) { 180 if($activeRule['endYear'] != self::MAX_YEAR_VALUE) { 181 $hasNonFinalRules = true; 182 break; 183 } 184 } 185 167 186 // remove all (still) active rules which don't apply anymore 168 187 foreach($activeRules as $activeRuleIdx => $activeRule) { … … 173 192 unset($activeRules[$activeRuleIdx]); 174 193 // protect against generating final rules, they are handled in the timezone implementation 175 } elseif($year != $activeRule['startYear'] && $ activeRule['endYear'] != self::MAX_YEAR_VALUE) {194 } elseif($year != $activeRule['startYear'] && $hasNonFinalRules) { 176 195 // if the year is the start year this rule has already been processed for this year 177 $time = $this->getOnDate($year, $activeRule['month'], $activeRule['on'], $myRule['at'], 0, $dstOff);196 $time = $this->getOnDate($year, $activeRule['month'], $activeRule['on'], $myRule['at'], 0, 0); 178 197 $myRules[] = array('time' => $time, 'rule' => $activeRule); 179 198 } … … 181 200 182 201 if($year == $myRule['startYear']) { 183 $time = $this->getOnDate($year, $myRule['month'], $myRule['on'], $myRule['at'], 0, $dstOff); 184 if($myRule['endYear'] != self::MAX_YEAR_VALUE) { 202 $time = $this->getOnDate($year, $myRule['month'], $myRule['on'], $myRule['at'], 0, 0); 203 204 if($myRule['endYear'] != self::MAX_YEAR_VALUE || $hasNonFinalRules) { 185 205 $myRules[] = array('time' => $time, 'rule' => $myRule); 186 206 } … … 217 237 throw new IllegalArgumentException('No rule with the name ' . $name . ' exists'); 218 238 } 239 240 $lastDstOff = 0; 219 241 220 242 $rules = array(); … … 231 253 $untilDate = $this->dateStrToArray($until); 232 254 $untilTime = $this->getOnDate($untilDate['year'], $untilDate['month'], array('type' => 'date', 'date' => $untilDate['day'], 'day' => null), array('secondsInDay' => $untilDate['time']['seconds'], 'type' => $untilDate['time']['type']), $gmtOff, $dstOff); 233 } 234 235 switch($rule['rule']['on']['type']) { 255 var_dump("$until: $untilTime " . gmdate('d.m.Y H:i:s', $untilTime)); 256 } 257 258 switch($rule['rule']['at']['type']) { 236 259 case 'wallclock': 237 $time -= $stdOff; 238 // the missing break is intentional ! 260 var_dump('wallclock on ' . $name . ' (' . gmdate('d.m.Y H:i:s', $time) . '): ' . $lastDstOff . ' ' . $gmtOff); 261 $time -= $lastDstOff; 262 $time -= $gmtOff; 263 break; 264 239 265 case 'standard': 266 var_dump('standard on ' . $name . ' (' . gmdate('d.m.Y H:i:s', $time) . '): ' . $gmtOff); 240 267 $time -= $gmtOff; 241 } 268 break; 269 } 270 271 $lastDstOff = $dstOff; 242 272 243 273 if($from !== null && $time < $from) { … … 246 276 continue; 247 277 } elseif($firstHit) { 248 $insertRuleName = sprintf(is_array($format) ? $format[0] : $format, $lastSkippedRule !== null ? $lastSkippedRule['rule']['variablePart'] : ''); 249 250 $rules[] = array( 251 'time' => $from, 252 'rawOffset' => $gmtOff, 253 'dstOffset' => 0, 254 'name' => $insertRuleName, 255 ); 278 if($from != $time) { 279 $insertRuleName = sprintf(is_array($format) ? $format[0] : $format, $lastSkippedRule !== null ? $lastSkippedRule['rule']['variablePart'] : ''); 280 281 $rules[] = array( 282 'time' => $from, 283 'rawOffset' => $gmtOff, 284 'dstOffset' => 0, 285 'name' => $insertRuleName, 286 ); 287 } else { 288 var_dump("hit $from on $time " . gmdate('d.m.Y H:i:s', $time)); 289 } 256 290 $firstHit = false; 257 291 } … … 323 357 324 358 if($lastRuleEndTime !== null) { 359 var_dump("adding last role $format : $lastRuleEndTime " . gmdate("d.m.Y H:i:s", $lastRuleEndTime)); 325 360 $myRules[] = array('time' => $lastRuleEndTime, 'rawOffset' => $gmtOff, 'dstOffset' => $dstOff, 'name' => $format); 326 361 } else { … … 680 715 $at = $ruleColumns[6]; 681 716 $lastAtChar = substr($at, -1); 682 $atType = 'wall Clock';717 $atType = 'wallclock'; 683 718 if($lastAtChar == 'w') { 684 719 $at = substr($at, 0, -1); … … 872 907 protected function dateStrToArray($date) 873 908 { 874 $array = array('year' => 0, 'month' => 1, 'day' => 1, 'time' => array('type' => 'wallclock', 'seconds' => 0));909 $array = array('year' => 0, 'month' => 0, 'day' => 1, 'time' => array('type' => 'wallclock', 'seconds' => 0)); 875 910 if(preg_match('!(\d{4})(\s+[a-z0-9]+)?(\s+\d+)?(\s+\d[^\s]*)?!i', $date, $match)) { 876 911 $match = array_map('trim', $match);

