From 0c2443159080d06ad0e1024007a8d0056936a35e Mon Sep 17 00:00:00 2001 From: defacer Date: Wed, 27 Apr 2005 03:42:07 +0000 Subject: [PATCH] Fix for bug 3045: Now usertimezone() gives a correct human-readable string in all cases. --- lib/moodlelib.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 14c5e1fd35d..bce2c34d281 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -823,19 +823,31 @@ function usergetmidnight($date, $timezone=99) { */ function usertimezone($timezone=99) { - $timezone = get_user_timezone_offset($timezone); + $tz = get_user_timezone($timezone); - if (abs($timezone) > 13) { - return 'server time'; + if (!is_float($tz)) { + return $tz; } - if (abs($timezone) < 0.5) { + + if(abs($tz) > 13) { // Server time + return get_string('serverlocaltime'); + } + + if($tz == intval($tz)) { + // Don't show .0 for whole hours + $tz = intval($tz); + } + + if($tz == 0) { return 'GMT'; } - if ($timezone > 0) { - return 'GMT+'. $timezone; - } else { - return 'GMT'. $timezone; + else if($tz > 0) { + return 'GMT+'.$tz; } + else { + return 'GMT'.$tz; + } + } /**