Facebook事件和时区,如何将UTC datetime转换为Facebook期望的? [英] Facebook Events and timezones, how to convert UTC datetime to what facebook expects?

查看:922
本文介绍了Facebook事件和时区,如何将UTC datetime转换为Facebook期望的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用需要创建Facebook事件。一切工作正常,但我无法得到时区正确。开始/结束日期都是错误的。 Facebook的Event API文件说:

My application needs to create facebook events. Everything works fine, but I can't get the timezones correct. The start/end dates are all wrong. Facebook's Event API docs say this:


注意:start_time和end_time是事件创建者输入的时间,转换为UTC后假设他们在太平洋时间(夏令时或标准,取决于事件的日期),然后转换为Unix时代。

Note: The start_time and end_time are the times that were input by the event creator, converted to UTC after assuming that they were in Pacific time (Daylight Savings or Standard, depending on the date of the event), then converted into Unix epoch time.

(来源)

我不知道这是什么意思。

I can't figure out what that means.

我的网络应用程序是一个python(django)站点。给定一个具有UTC开始/结束时间的 datetime 对象,什么是 pytz 调用获得的魔法咒语发送到Facebook的正确时间?

My web application is a python (django) site. Given a datetime object which has the start/end time in UTC, what is the magical incantation of pytz calls to get the correct time to send to facebook?

推荐答案

Unix时代简单地表示1970年1月1日以来的秒数(不计算闰秒)。

"Unix epoch time" simply means "number of seconds since January 1, 1970 (not counting leap seconds)".

顺便说一句,Facebook Event API的描述是如此奇怪,我不敢相信它是正确的描述。他们似乎要求的是:

By the way, that Facebook Event API description is so bizarre, I can't believe it is right as described. What they seem to be asking for is:


  1. 事件创建者输入的时间;

  2. 解释为太平洋时区的本地时间,该区域的夏令时规则生效;

  3. 转换为UTC。

我住在时区UTC + 0。所以如果我在2010-11-09 12:00 UTC UTC安排一个事件,实际提交给Facebook的时间是(对应于Unix时间)2010-11-09 20:00:00 UTC。那怎么可能呢?也许我误会了。

I live in the timezone UTC+0. So if I schedule an event at 2010-11-09 12:00:00 UTC, the time that actually gets submitted to Facebook is (the Unix time corresponding to) 2010-11-09 20:00:00 UTC. How can that be right? Maybe I've misunderstood.

这篇关于Facebook事件和时区,如何将UTC datetime转换为Facebook期望的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆