MDL-54008 tz: Unexisting tz with decimals fallback to rounded down integer
This commit is contained in:
@@ -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])) {
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user