From 798065253eb88f75e325485044e2b8ecb254d30f Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Sat, 2 Apr 2005 06:28:02 +0000 Subject: [PATCH] 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. --- lib/olson.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/olson.php b/lib/olson.php index 02c85dc3f3b..743946759e8 100644 --- a/lib/olson.php +++ b/lib/olson.php @@ -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]); }