Two minor fixes to Olson file parsing. olson_parse_at() now deals correctly with 'unsigned' AT entries. olson_simple_rule_parser() avoid a potential bug in minute-only SAVE entries.

This commit is contained in:
martinlanghoff
2005-04-02 06:28:02 +00:00
parent d11c7c9b34
commit 798065253e
+10 -4
View File
@@ -274,8 +274,14 @@ function olson_simple_rule_parser ($filename) {
$moodle_rule = array();
list($hours, $mins) = explode(':', $save);
$save = $hours * 60 + $mins;
// $save is sometimes just minutes
// and othertimes HH:MM -- only
// parse if relevant
if (!preg_match('/^\d+$/', $save)) {
list($hours, $mins) = explode(':', $save);
$save = $hours * 60 + $mins;
}
// we'll parse $at later
// $at = olson_parse_at($at);
$in = strtolower($in);
@@ -586,7 +592,7 @@ function olson_parse_at ($at, $set = 'set', $gmtoffset) {
// find the time "signature";
$sig = '';
if (preg_match('/\w$/', $at, $matches)) {
if (preg_match('/[ugzs]$/', $at, $matches)) {
$sig = $matches[0];
$at = substr($at, 0, strlen($at)-1); // chop
}
@@ -617,7 +623,7 @@ function olson_parse_at ($at, $set = 'set', $gmtoffset) {
return sprintf('%02d:%02d', $hours, $mins);
}
trigger_error('unhandled case - AT flag is ' . $matches[0]);
trigger_error('unhandled case - AT flag is ' . $matches[0]);
}