From bf617f07a6929843137d45d278eb2b4c4b6ec588 Mon Sep 17 00:00:00 2001 From: defacer Date: Mon, 24 Oct 2005 17:31:40 +0000 Subject: [PATCH] Merging from HEAD: Fix for bug 3794: Times in chat messages are now displayed correctly to all users, with each user's timezone and DST status taken into account. --- mod/chat/lib.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 0493234778a..bbb0658b544 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -494,17 +494,20 @@ function chat_update_chat_times($chatid=0) { function chat_format_message_manually($message, $courseid, $sender, $currentuser, $chat_lastrow=NULL) { - global $CFG; + global $CFG, $USER; $output = New stdClass; $output->beep = false; // by default $output->refreshusers = false; // by default - // Get some additional info + // Use get_user_timezone() to find the correct timezone for displaying this message: + // It's either the current user's timezone or else decided by some Moodle config setting + $tz = get_user_timezone($currentuser->timezone); - // But before that :-) let's override get_user_timezone_offset() for this call... messy stuff... - // TODO - FIX THIS TO MANAGE NEW TIMEZONES - $tz = ($currentuser->timezone == 99) ? $CFG->timezone : $currentuser->timezone; + // Before formatting the message time string, set $USER->timezone to the above. + // This will allow dst_offset_on (called by userdate) to work correctly, otherwise the + // message times appear off because DST is not taken into account when it should be. + $USER->timezone = $tz; $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz); $message->picture = print_user_picture($sender->id, 0, $sender->picture, false, true, false);