uddeim displays wrong time

13 years 6 months ago #145249 by slabbi
Replied by slabbi on topic Re:uddeim displays wrong time
In uddeIM backend (date/time tab) you can adjust the timezone.

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in to join the conversation.

13 years 6 months ago #145278 by drdehart
Replied by drdehart on topic Re:uddeim displays wrong time
yes, but that is just a static setting. We want each user to see the time in their own time zone. For instance, the site and uddeim time is set to Pacific time (GMT-8), but we have many users in other time zones (GMT-7, -6, -5) and when they sent messages, the message time is not in their time zone.

So we want each user to see message dates and times based on their own time zone. So if I send a message on 1 November, 2010 at 22:00 from the Pacific time zone (GMT-8) to a user in the Eastern time zone (GMT-5), the date/time for them would be 2 November, 2010 at 01:00.

Post edited by: drdehart, at: 2010/11/01 20:08

Please Log in to join the conversation.

13 years 6 months ago #145280 by slabbi
Replied by slabbi on topic Re:uddeim displays wrong time
I understand. Because of the backward compatibility to Joomla 1.0 this feature has not been implemented yet.

I will try to add it to the release (uddeIM 2.2).

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in to join the conversation.

13 years 6 months ago #145281 by drdehart
Replied by drdehart on topic Re:uddeim displays wrong time
That would be great!:woohoo:

Please Log in to join the conversation.

13 years 6 months ago #145298 by slabbi
Replied by slabbi on topic Re:uddeim displays wrong time
Maybe I have a quick'n'dirty fix for you. It does only work on Joomla 1.5 (J1.0 please don't try that, it will not work).

Change (in admin.shared.php)

[code:1]function uddetime($timezone = 0) {
$mosConfig_offset = uddeIMgetOffset();
$rightnow=time()+(($mosConfig_offset+$timezone)*3600);
return $rightnow;
}
[/code:1]

to

[code:1]function uddetime($timezone = 0) {
$user =& JFactory::getUser();
$usertz = $user->getParam('timezone');
$mosConfig_offset = $usertz;
$rightnow=time()+(($mosConfig_offset+$timezone)*3600);
return $rightnow;
}
[/code:1]

It adds the user's timezone to the calculated time. It will not change the already existing messages, new messages should have the correct time when the timezone is set in the users profile.

When it does not work there is a second solution:

[code:1]function uddetime($timezone = 0) {
$JDate = JFactory::getDate();
$JUser =& JFactory::getUser();
$JDate->setOffset($JUser->getParam('timezone'));
$date2 = $JDate->toUnix();
$rightnow=$date2+($timezone*3600);
return $rightnow;
}
[/code:1]

The second solution uses Joomla framework to get the date/time and adds the uddeIM timezone correction factor if needed.


Note: I was not able to test it since my test server is currently broken and needs to be reinstalled. Maybe you can check if it works.

Post edited by: slabbi, at: 2010/11/01 21:07

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in to join the conversation.

13 years 6 months ago #145351 by slabbi
Replied by slabbi on topic Re:uddeim displays wrong time
Well, checked it on another test server and the solution in the previous post is 95% working ;)

This should do the job:

[code:1]function uddetime($timezone = 0) {
$JDate = JFactory::getDate();
$JUser =& JFactory::getUser();
$tz = $JUser->getParam('timezone');
$JDate->setOffset($tz);
$date2 = $JDate->toUnix()+(3600*$tz); // toUnix does not include timezone, so add it here
$rightnow=$date2+($timezone*3600);
return $rightnow;
}[/code:1]

Note:
It is still possible to adjust the timezone in uddeIM globally which is useful when the server admin as not configured the correct timezone or the server clock is not set correctly. When the server time is set correctly, the tomezone correctin factor in uddeIM backend (date/time tab) should be "0"!

Note 2:
This hack is not supported. In uddeIM 2.2 I will find a better solution.

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in to join the conversation.

Moderators: beatnantslabbikrileon
Time to create page: 0.426 seconds

Facebook Twitter LinkedIn