【问题标题】:Zend Google Calendar API - Add Event is One Hour offZend Google Calendar API - 添加事件是一小时
【发布时间】:2012-09-23 21:03:09
【问题描述】:
当我使用 Zend API 添加事件时,夏季夏令时月份的时间是一小时。
我用于添加日期的字符串是“2012-10-02T06:00:00-05:00”。我在东部时区,我的 Google 日历也设置为东部时区,但时间显示为早上 7 点。
我也试过“2012-10-02T06:00:00.000-05:00”。
我也尝试过使用 date_default_timezone_set("America/Detroit")。
有什么想法吗?我一直在研究并尝试解决这个问题。
谢谢。
【问题讨论】:
标签:
zend-framework
timezone
google-calendar-api
【解决方案1】:
我确实将时区标识符应用于我的条目。我使用 -05:00 --> "2012-10-02T06:00:00-05:00"
我认为 setTimezone 只适用于 Zend_Date
【解决方案2】:
Zend_Gdata_Calendar_EventEntry 允许您调用 getTimezone() 和 setTimezone() 并且您应该能够将时区标识符应用于您的条目或 UTC 偏移量。
"end": {
"dateTime": "2012-07-12T10:30:00.0z" //z is identifier for UTC
},
"start": {
"dateTime": "2012-07-12T09:30:00.0z"
}
"start": {
"dateTime": "2012-07-11T03:30:00-06:00" //-06:00 would be UTC offset
},
"end": {
"dateTime": "2012-07-11T04:30:00-06:00"
}
【解决方案3】:
如果您查看 google calendar API,您会注意到事件 dateTime 必须以 RFC 3339 格式传递(根据您在问题中给出的示例,您已经知道)。
specification for the rfc 3339 format 声明:
因为当地时区的夏令时规则是如此
令人费解,并且可能在不可预测的时间根据当地法律发生变化,
真正的互操作性最好通过使用 Coordinated Universal 来实现
时间 (UTC)。本规范不符合当地时区
规则。
这基本上意味着该规范不考虑 DST。基本上,在将日期传递给 Google 日历 API 之前,您需要自行调整 DST。