Permalink
Browse files

olson_simple_rule_parser() now adds a reset rule to rulesets where th…

…e last rule has a defined TO field that marks where it ends. This tonge-twister means that Asia/Seoul should see the 1987 DST rule deactivated correctly in modern times. Discussed in http://moodle.org/mod/forum/discuss.php?d=23957
  • Loading branch information...
1 parent 1741e5f commit 6227e876f65b1406122cfdaee0380a76601308c7 martinlanghoff committed May 18, 2005
Showing with 24 additions and 2 deletions.
  1. +24 −2 lib/olson.php
View
@@ -332,9 +332,31 @@ function olson_simple_rule_parser ($filename) {
$moodle_rules[$moodle_rule['name']][$moodle_rule['year']] = $moodle_rule;
//print_object($moodle_rule);
- }
- }
+ } // end foreach year within a rule
+
+ // completed with all the entries for this rule
+ // if the last entry has a TO other than 'max'
+ // then we have to deal with closing the last rule
+ //trigger_error("Rule $name ending to $to");
+ if (!empty($to) && $to !== 'max') {
+ // We can handle two cases for TO:
+ // a year, or "only"
+ $reset_rule = $moodle_rule;
+ $reset_rule['dstoff'] = '00';
+ if (preg_match('/^\d+$/', $to)){
+ $reset_rule['year'] = $to;
+ $moodle_rules[$reset_rule['name']][$reset_rule['year']] = $reset_rule;
+ } elseif ($to === 'only') {
+ $reset_rule['year'] = $reset_rule['year'] + 1;
+ $moodle_rules[$reset_rule['name']][$reset_rule['year']] = $reset_rule;
+ } else {
+ trigger_error("Strange value in TO $to rule field for rule $name");
+ }
+
+ } // end if $to is interesting
+
+ } // end foreach rule
return $moodle_rules;
}

0 comments on commit 6227e87

Please sign in to comment.