Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-36773 timezone inconsistency => some number support decimal other…

… don\'t - Original patch author: Nathan Mares
  • Loading branch information...
commit 8158ce79f9a1be3a8a3fcba7f236e0f3d70a8602 1 parent f42c34a
@mouneyrac mouneyrac authored
Showing with 15 additions and 1 deletion.
  1. +1 −1  lib/moodlelib.php
  2. +14 −0 lib/tests/moodlelib_test.php
View
2  lib/moodlelib.php
@@ -1134,7 +1134,7 @@ function clean_param($param, $type) {
case PARAM_TIMEZONE: //can be int, float(with .5 or .0) or string seperated by '/' and can have '-_'
$param = fix_utf8($param);
- $timezonepattern = '/^(([+-]?(0?[0-9](\.[5|0])?|1[0-3]|1[0-2]\.5))|(99)|[[:alnum:]]+(\/?[[:alpha:]_-])+)$/';
+ $timezonepattern = '/^(([+-]?(0?[0-9](\.[5|0])?|1[0-3](\.0)?|1[0-2]\.5))|(99)|[[:alnum:]]+(\/?[[:alpha:]_-])+)$/';
if (preg_match($timezonepattern, $param)) {
return $param;
} else {
View
14 lib/tests/moodlelib_test.php
@@ -943,9 +943,23 @@ function test_clean_param_timezone() {
'0' => '0',
'0.0' => '0.0',
'0.5' => '0.5',
+ '9.0' => '9.0',
+ '-9.0' => '-9.0',
+ '+9.0' => '+9.0',
+ '9.5' => '9.5',
+ '-9.5' => '-9.5',
+ '+9.5' => '+9.5',
+ '12.0' => '12.0',
+ '-12.0' => '-12.0',
+ '+12.0' => '+12.0',
+ '12.5' => '12.5',
'-12.5' => '-12.5',
'+12.5' => '+12.5',
+ '13.0' => '13.0',
+ '-13.0' => '-13.0',
+ '+13.0' => '+13.0',
'13.5' => '',
+ '+13.5' => '',
'-13.5' => '',
'0.2' => '');
Please sign in to comment.
Something went wrong with that request. Please try again.