<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>henkude &#187; timezone</title>
	<atom:link href="http://henkude.com/blog/tag/timezone/feed/" rel="self" type="application/rss+xml" />
	<link>http://henkude.com</link>
	<description>hen - very, ku - cool, de - 的</description>
	<lastBuildDate>Fri, 21 May 2010 14:41:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>The time machine of BuddyPress taking everything nearby back to memory</title>
		<link>http://henkude.com/blog/2009/10/27/the-time-machine-of-buddypress-taking-everything-nearby-back-to-memory/</link>
		<comments>http://henkude.com/blog/2009/10/27/the-time-machine-of-buddypress-taking-everything-nearby-back-to-memory/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 13:37:52 +0000</pubDate>
		<dc:creator>Kude Hen</dc:creator>
				<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[timezone]]></category>

		<guid isPermaLink="false">http://henkude.com/?p=24</guid>
		<description><![CDATA[终于搞明白了 BuddyPress 这个诡异的时间问题。 按照 web app 的常识，主程序设定用户时区便可以正常显示，然而在 BuddyPress 并不是这样，它是 WPMU 的一个插件，它的相对时间首先看齐于 group/forum/status/wire 这些 BuddyPress 组件，对于 WPMU 的 blog 组件实际上处于一个平行关系，再加上 WPMU 的多用户 blog，每个用户的 blog 有可能设置不同的时区，BuddyPress 产生时间混沌看上去是一件不可避免的事情，不过这并不是什么坏事，这只是产品成熟过程中的一个里程碑，目前来说，无论 BuddyPress 的站长身处哪个时区，都必须将主 blog (也就是 WPMU 安装时的默认初始 blog) 的时区对准服务器所在的时区，这看上去像一个内部框架向主框架的反包围，不过这确实解决了 BuddyPress 首页的全站动态 (Site Wide Activity) 时间线混乱的问题，唯一的副作用就是，凡是主 blog 的 post 时间都是服务器时间，而非用户身处的时区了。 Finally, we approached in a solution of this weird BuddyPress &#8220;since&#8221; time [...]]]></description>
			<content:encoded><![CDATA[<p>终于搞明白了 BuddyPress 这个诡异的时间问题。</p>
<p>按照 web app 的常识，主程序设定用户时区便可以正常显示，然而在 BuddyPress 并不是这样，它是 WPMU 的一个插件，它的相对时间首先看齐于 group/forum/status/wire 这些 BuddyPress 组件，对于 WPMU 的 blog 组件实际上处于一个平行关系，再加上 WPMU 的多用户 blog，每个用户的 blog 有可能设置不同的时区，BuddyPress 产生时间混沌看上去是一件不可避免的事情，不过这并不是什么坏事，这只是产品成熟过程中的一个里程碑，目前来说，无论 BuddyPress 的站长身处哪个时区，都必须将主 blog (也就是 WPMU 安装时的默认初始 blog) 的时区对准服务器所在的时区，这看上去像一个内部框架向主框架的反包围，不过这确实解决了 BuddyPress 首页的全站动态 (Site Wide Activity) 时间线混乱的问题，唯一的副作用就是，凡是主 blog 的 post 时间都是服务器时间，而非用户身处的时区了。<br />
 <span id="more-24"></span><br />
 Finally, we approached in a solution of this weird BuddyPress &#8220;since&#8221; time phenomenon.</p>
<p>Usually, the time/date mechanism of a web app will run responsively after the user timezone is set, that doesn&#8217;t happen to BuddyPress since it&#8217;s a plugin of WPMU, actually, it serves group/forum/status/wire components, and keeps a parallel relationship with WPMU, which is designed to be multi-user platform. Every user in a WPMU site could have his/her blog timezone set separately, this convenience has its little buddy plugin an inevitable destiny of timeline chaos. After all, that&#8217;s not so bad, it leads to a milestone of the product development.</p>
<p>For now, wherever the webmaster of a WPMU+BuddyPress community site is hosted, he/she will have no alternative but set the timezone of default blog (automatically created by WPMU installation) to notch the hosting server system time, which look like a subframework fights back its parent framework, but the phenomenon is eliminated, the &#8220;since&#8221; time in Site Wide Activity stream is back to peace again, regardless of the post on default admin blog being published on server time instead of the timezone user stays in.</p>
<div class="shr-publisher-24"></div>]]></content:encoded>
			<wfw:commentRss>http://henkude.com/blog/2009/10/27/the-time-machine-of-buddypress-taking-everything-nearby-back-to-memory/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>BuddyPress 很酷的时区问题暂时得以解决</title>
		<link>http://henkude.com/blog/2009/10/25/buddypress-timezone-bug-temporar-solution/</link>
		<comments>http://henkude.com/blog/2009/10/25/buddypress-timezone-bug-temporar-solution/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 20:23:20 +0000</pubDate>
		<dc:creator>Kude Hen</dc:creator>
				<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[timezone]]></category>

		<guid isPermaLink="false">http://henkude.com/?p=10</guid>
		<description><![CDATA[/wp-content/plugins/buddypress/bp-core.php, line 1289 &#8211; line 1292: 1234$since = $newer_date - $older_date;&#60;/p&#62; &#60;p&#62;if &#40; 0 &#38;gt; $since &#41;&#60;br /&#62; &#160;return __&#40; '[Use GMT Timezone]', 'buddypress' &#41;; 改成 12345$since = $newer_date - $older_date - 50400;&#60;/p&#62; &#60;p&#62;if &#40; 0 &#38;gt; $since &#41;&#60;br /&#62; &#160;$since = $since + 50400;&#60;br /&#62; &#160;//        return __( '[Use GMT Timezone]', 'buddypress' ); [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: #008000">/wp-content/plugins/buddypress/bp-core.php, line 1289 &#8211; line 1292:</span></strong></p>
<p><div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$since</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$newer_date</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$older_date</span><span style="color: #339933;">;&lt;/</span>p<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>if <span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$since</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span>br <span style="color: #339933;">/&gt;</span><br />
&nbsp;<span style="color: #b1b100;">return</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'[Use GMT Timezone]'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'buddypress'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
</p>
<p>改成</p>
<p><div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$since</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$newer_date</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$older_date</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50400</span><span style="color: #339933;">;&lt;/</span>p<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>if <span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$since</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span>br <span style="color: #339933;">/&gt;</span><br />
&nbsp;<span style="color: #000088;">$since</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$since</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">50400</span><span style="color: #339933;">;&lt;</span>br <span style="color: #339933;">/&gt;</span><br />
&nbsp;<span style="color: #666666; font-style: italic;">//        return __( '[Use GMT Timezone]', 'buddypress' );</span></div></td></tr></tbody></table></div>
</p>
<p>50400 是本地时间和服务器时间的时间差，以秒计，henkude 服务器在 UTC-6，而我们都在 UTC+8，因此相差14个小时，也就是50400秒，之所以要在后面再加回去是因为 BuddyPress 的这个 bug 只存在于全站动态 (Site Wide Activity) 里，其他地方都 OK，所以当这个值为负值时，只有全站动态里是正常的，其他地方就只能显示 Use GMT Timezone，所以要加回去才能正确显示。</p>
<p>归根究底，BuddyPress 是 WPMU 的一个插件，不知道为什么会使用两套时间戳算法，在 BuddyPress 官网上找了半天，只找到自己大半年前去问这个问题的<a href="http://buddypress.org/forums/topic/timezone-problem" target="_blank">帖子</a>，还是被一个老外 moderator 揶揄了一番，郁闷。虽然也有说 trac 里面给出了补丁，可是怎么翻也没翻到，简直是一片混战。论坛上有人了<a href="http://buddypress.org/forums/topic/adjust-time-zone#post-13371" target="_blank">这么个临时解决方法</a>，没时间测试了，貌似也没我这样省事。</p>
<p><strong><span style="color: #ff0000">Update:</span></strong> 这个方法在 BP 安装24小时后开始失效，据官方论坛称，BP 的相对时间问题会在安装后24小时自动纠正，但实际上 blog 输出到全站动态的时间是正确的，而论坛帖子输出的时间确实服务器的时间而不是用户设定的本地时间，这个问题已经<a href="http://trac.buddypress.org/ticket/1274" target="_blank">提交到 BP 的 trac</a>，不知道会不会有下文，这实在是个历史悠久的老虫子了。<a href="http://dl.getdropbox.com/u/128925/buddypress-time-problem.png" target="_blank">附一张截图说明</a>。</p>
<div class="shr-publisher-10"></div>]]></content:encoded>
			<wfw:commentRss>http://henkude.com/blog/2009/10/25/buddypress-timezone-bug-temporar-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

