MDL-50704 date: Fix invalid timezone mapping for +14

The value Etc/GMT-14 was added to the list of known timezones,
and Etc/GMT+13 & Etc/GMT+14 were removed as they are not valid.

Tests were added to ensure that legacy user timezones are mapped
to known timezones. Other tests were changed to reflect the changes
with regards to Etc/GMT+13 and +-14.
This commit is contained in:
Frederic Massart
2016-05-09 17:36:36 +08:00
parent d97b3d4c81
commit 396e1a76d3
3 changed files with 80 additions and 6 deletions
+7 -3
View File
@@ -72,8 +72,12 @@ class core_date {
if (is_numeric($currentvalue)) {
// UTC offset.
$modifier = ($currentvalue > 0) ? '+' : '';
$a = 'UTC' . $modifier . number_format($currentvalue, 1);
if ($currentvalue == 0) {
$a = 'UTC';
} else {
$modifier = ($currentvalue > 0) ? '+' : '';
$a = 'UTC' . $modifier . number_format($currentvalue, 1);
}
$timezones[$currentvalue] = get_string('timezoneinvalid', 'core_admin', $a);
} else {
// Some string we don't recognise.
@@ -508,7 +512,7 @@ class core_date {
);
// Legacy GMT fallback.
for ($i = -14; $i <= 13; $i++) {
for ($i = -12; $i <= 14; $i++) {
$off = abs($i);
if ($i < 0) {
$mapto = 'Etc/GMT+' . $off;