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:
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.
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?
It means that if the user enters "12 am" you're supposed to assume its "12 am pacific time", convert that to UTC so its "8 am GMT" and turn that into a unix epoch.
You can do it like this:
"Unix epoch time" simply means "number of seconds since January 1, 1970 (not counting leap seconds)".
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:
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.