MDL-54008 tz: Unexisting tz with decimals fallback to rounded down integer

This commit is contained in:
David Monllao
2016-05-03 14:03:09 +08:00
parent bfb122a10a
commit 143f410a2f
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -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])) {
+4
View File
@@ -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'));
}
}