diff --git a/lib/classes/date.php b/lib/classes/date.php index 6026bb91e72..3685809eb4f 100644 --- a/lib/classes/date.php +++ b/lib/classes/date.php @@ -134,7 +134,7 @@ class core_date { // Convert to known zone. $tz = self::$badzones[$tz]; $fixed = true; - } else if (is_number($tz)) { + } else if (is_numeric($tz)) { // Half hour numeric offsets were already tested, try rounding to integers here. $roundedtz = (string)(int)$tz; if (isset(self::$badzones[$roundedtz])) { diff --git a/lib/tests/date_legacy_test.php b/lib/tests/date_legacy_test.php index 09ddf026a84..758416373a9 100644 --- a/lib/tests/date_legacy_test.php +++ b/lib/tests/date_legacy_test.php @@ -339,5 +339,9 @@ class core_date_legacy_testcase extends advanced_testcase { $USER->timezone = 'Europe/Prague'; $this->assertSame('Europe/Prague', usertimezone('99')); + + // Checking fallback with an unexisting timezone. + $USER->timezone = '-9.23'; + $this->assertSame('UTC-9', usertimezone('99')); } }