时区问题FQL表'事件'中的时间戳

时间:2011-09-28 12:16:08

标签: timezone facebook-fql

我在start_time FQL表的end_timeevent字段中遇到事件时区问题。我想在格式化日期中显示时间戳,该日期考虑了用户时区。根据经验,时间戳似乎在PST时区中,因此我将它们转换为GMT并添加用户时区,如timezone表中的user字段所示。转换为GMT由Java执行,具有以下代码(这应该自动考虑夏令时):

long millis = 1000 * timestamp;
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
int offset = tz.getOffset(millis);
long timestampGMT = millis + offset;

然而,这种方法产生的结果与Facebook网站不同。 例如,我有start_time = 1317416400的事件和timezone = 2的用户。转换为GMT并添加用户时区我将于2011年9月30日16:00:00,但Facebook网站显示2011年9月30日14:00:00。

如何获得正确的(如在FB网站中)结果?

示例:

Summer:
http://www.facebook.com/event.php?eid=234094353309432
Created by a user on GMT+2
Time shown on the site: Friday, September 30 · 2:00pm - 7:00pm
start_time (from FQL): 1317416400
If it was UTC, then: Friday, September 30th 2011, 21:00:00 (GMT)
If it was PDT (with DST, so GMT-7), then: Friday, September 30th 2011, 14:00:00 (GMT-7)

Winter:
http://www.facebook.com/event.php?eid=254174591293234
Created by a user on GMT+2
Time shown on the site: Sunday, December 25 · 1:00pm - 4:00pm
start_time (from FQL): 1324846800
If it was UTC, then: Sunday, December 25th 2011, 21:00:00 (GMT)
If it was PST (no DST, so GMT-8), then: Sunday, December 25th 2011, 13:00:00 (GMT-8)

由于

0 个答案:

没有答案