Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Fix vbShout Timezone problem Details »»
Fix vbShout Timezone problem
Version: 1.00, by newhere newhere is offline
Developer Last Online: Dec 2009 Show Printable Version Email this Page

Category: Chat Modifications - Version: 3.6.5 Rating:
Released: 04-09-2007 Last Update: Never Installs: 13
 
No support by the author.

This vbShout plugin: http://www.vbhackers.com/f76/ajax-fl...ut-2-1-a-4536/

Has a serious bug with Time Zone changing to that of the last person to post in the shout box.

Here is a fix so that each user will see the time in their local timezone correctly.

1. Open template forumhome_vbshout_shout
Find this (should be at the very beginning):
Code:
<tr>
After it add:
Code:
                                <td nowrap align="left" valign="top">
                                <font size="1">
                                    <date>{$Shout['time']}</date>
                                    
                                </font>
                                </td>
Make sure that the "date" and "/date" tags are on the same line, and with no spaces between them and the $Shout variable, just as above. These are not valid html tags, and we are going to write code to replace them ourselves.



2. Open template forumhome_vbshout
Find:
Code:
Shouts.innerHTML = '<table cellpadding="1" cellspacing="3" border="0" width="95%" align="left">' + ShoutRequest.handler.responseText + '</table>'
Replace it with:
Code:
                        var formatMe = ShoutRequest.handler.responseText
			formatMe = replaceDates(formatMe);
                        Shouts.innerHTML = '<table cellpadding="1" cellspacing="0" border="0" width="100%" align="left">' + formatMe + '</table>'
In the same template
Find this:
Code:
function sb_CollectHV(sbForm)
Before it add:
Code:
// replaces <date> tags
function replaceDates(s) {
            var ret = "";
            var matches = s.match(/<date>\d+<\/date>/g);
            for(var i = 0; matches != null && i < matches.length; i++) {
                var utc = matches[i].match(/\d+/);
                var date = new Date(utc * 1000);
                ret = ret + s.substr(0, s.indexOf(matches[i]));
                ret = ret + (date.getMonth()+1) + "/" +
                            date.getDate() + "/" +
                            date.getFullYear() + " " +
                            date.getHours() + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + ":" +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + " ";


                s = s.substr(s.indexOf(matches[i]) + matches[i].length);
            }
            ret = ret + s;
            return ret;
}



3. Open file vbshout.php
FInd this (There are similar code blocks, this should be in the function rewrite_shoutbox_flatfile() around line 226):
Code:
        $Shout['time']     = buildTime($Shout['s_time']);
        $Shout['s_shout']  = bbcodeparser($Shout['s_shout']);
        $Shout['style']    = '';
        $Shout['data']     = unserialize($Shout['s_data']);
        $Shout['username'] = fetch_musername($Shout, 'usergroupid');

        if (preg_match("#(\#)?0099FF#i", $Shout['data']['color']) && $Shout['s_by'] != 1)
        {
            $Shout['data']['color'] = '';
        }
Replace it with:
Code:
        // $Shout['time']     = buildTime($Shout['s_time']);
        $Shout['time']     = $Shout['s_time'];
        $Shout['s_shout']  = bbcodeparser($Shout['s_shout']);
        $Shout['style']    = '';
        $Shout['data']     = unserialize($Shout['s_data']);
        $Shout['username'] = fetch_musername($Shout, 'usergroupid');
        
        if (preg_match("#(\#)?0099FF#i", $Shout['data']['color']) && $Shout['s_by'] != 1)
        {
            $Shout['data']['color'] = '';
        }

This should now pass the date as UTC and JavaScript will convert it on the client side to the appropriate date.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 04-10-2007, 02:44 AM
dbirosel dbirosel is offline
 
Join Date: Feb 2007
Location: San Diego
Posts: 587
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by newhere View Post
For formatting, you can change the function:
"replaceDates(s)"

Here:
Code:
                ret = ret + (date.getMonth()+1) + "/" +
                            date.getDate() + "/" +
                            date.getFullYear() + " " +
                            date.getHours() + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + ":" +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + " ";
To whatever you like.
Does this code also change from 24 hour to 12 hour time?
Reply With Quote
  #13  
Old 04-10-2007, 02:45 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dbirosel View Post
just looks kinda ugly. lol :P
Sorry, I have a lot of custom code on my install.
In that initial template edit, try setting font size="2" instead of size="1", or change the td attributes to otherwise match what your tables look like.

Code:
                                <td nowrap align="left" valign="top">
                                <font size="1">
                                    <date>{$Shout['time']}</date>
                                    
                                </font>
                                </td>
Reply With Quote
  #14  
Old 04-10-2007, 02:48 AM
dbirosel dbirosel is offline
 
Join Date: Feb 2007
Location: San Diego
Posts: 587
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks newhere! Loving the support so far!
Reply With Quote
  #15  
Old 04-10-2007, 02:54 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dbirosel View Post
Thanks newhere! Loving the support so far!
It's kind of an ugly hack around this static html nonsense. But it works. It was not acceptable to me to have no timestamp on shouts, and it was also not acceptable to have timezone constantly changing to whatever timezone of the last user posting a shout.
Reply With Quote
  #16  
Old 04-10-2007, 02:58 AM
Tulsa Tulsa is offline
 
Join Date: Jul 2005
Location: Broken Arrow, Oklahoma
Posts: 475
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for this...

If anyone had the time showing before and now you've got a bunch of numbers after the date/time and before the name in the forumhome_vbshout_shout, you probably added this line to it
Code:
{$Shout['time']}
remove it to remove those numbers.

Now how to get rid of the date and just have the time...
Reply With Quote
  #17  
Old 04-10-2007, 02:59 AM
dbirosel dbirosel is offline
 
Join Date: Feb 2007
Location: San Diego
Posts: 587
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Didn't see you answer this yet, but is it possible to change it from 24 hour to 12 hour instead?
Reply With Quote
  #18  
Old 04-10-2007, 03:01 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tulsa View Post
Now how to get rid of the date and just have the time...
You can format the date however you want if you know a bit of javascript:
From my post above
https://vborg.vbsupport.ru/showpost....6&postcount=10
Reply With Quote
  #19  
Old 04-10-2007, 03:06 AM
Tulsa Tulsa is offline
 
Join Date: Jul 2005
Location: Broken Arrow, Oklahoma
Posts: 475
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by newhere View Post
You can format the date however you want if you know a bit of javascript:
From my post above
https://vborg.vbsupport.ru/showpost....6&postcount=10
(IF) would be the key word in that line..

I can delete with the best of the them however..

the date is gone.
Reply With Quote
  #20  
Old 04-10-2007, 03:16 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dbirosel View Post
Didn't see you answer this yet, but is it possible to change it from 24 hour to 12 hour instead?
for 12 hour time with brackets:

replace
Code:
                ret = ret + (date.getMonth()+1) + "/" +
                            date.getDate() + "/" +
                            date.getFullYear() + " " +
                            date.getHours() + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + ":" +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + " ";
with
Code:
                var append = "AM";
                var hour = date.getHours();
                if(hour > 12) {
                    hour = hour - 12;
                    append = "PM";
                }
                if(hour == 0) {
                    hour = 12;
                    append = "AM";
                }
                ret = ret + "[" + (date.getMonth()+1) + "/" +
                            date.getDate() + "/" +
                            date.getFullYear() + " " +
                            hour + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + " " +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + " " + append + "]";
Reply With Quote
  #21  
Old 04-10-2007, 03:19 AM
dbirosel dbirosel is offline
 
Join Date: Feb 2007
Location: San Diego
Posts: 587
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Omg perfect!!!! Thanks alot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:34 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08315 seconds
  • Memory Usage 2,324KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (13)bbcode_code
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete