日历中的Outlook API时间差异
问题描述:
我对使用Outlook API特别与Calendar API有关的问题。日历中的Outlook API时间差异
我用UTC格式发送日期,当它们添加到日历中时,我与发送日期有所不同。
我在法国,所以原始日期是UTC + 2。我转换成UTC,让我这个配置要求:
var options = {
url: "https://outlook.office.com/api/v2.0/me/calendars/" + workspace.calendarId + "/events?$Select=Id",
method: "POST",
headers: {
"authorization": "Bearer " + host.outlookCalAccessToken,
"accept" : "application/json",
"ContentType" : "application/json"
},
json:{
"Subject" : event.summary,
"Body" : {
"ContentType" : "Text",
"Content" : event.description
},
"Start" : {
"DateTime":start,
"TimeZone" : "OriginStartTimeZone"
},
"End" : {
"DateTime":end,
"TimeZone" : "OriginStartTimeZone"
},
"Attendees" : [
{
"EmailAddress" : {
"Name" : nomad.firstname,
"Address" : nomad.email
},
"Type" : "Required"
}
]
},
"Content-Type" : "application/json"
};
我有同样的问题,如果时区为“OriginStartTimeZone”或“UTC”。
例如,我的本地日期是2017-10-19T17:00:00.000
它转换为UTC 2017-10-19T15:00:00.000Z
而在日历事件日期是2017-10-19T08:00:00.000
有什么我错过了这个API?
谢谢!
答
如果你希望你的事件开始日期是二零一七年十月十九日在10:30本地时间,你的起始对象应该是这样的:
Start:{DateTime: "2017-10-19T10:30:00+02:00", TimeZone: "UTC"}
这是你的起始对象是什么样子?如果确实如此,则应在日历中正确显示事件时间。
答
OriginStartTimeZone
对于TimeZone
不是有效值。如果您将TimeZone
设置为UTC
,您应该可以得到预期的结果。我只是用这个有效载荷测试,在这里:
{
"Subject" : "test",
"Body" : {
"ContentType" : "Text",
"Content" : "hello"
},
"Start" : {
"DateTime": "2017-10-19T15:00:00.000Z",
"TimeZone" : "UTC"
},
"End" : {
"DateTime": "2017-10-19T16:00:00.000Z",
"TimeZone" : "UTC"
}
}
无论是在回应我的职务,并为事件后续GET请求,我回来:
"Start": {
"DateTime": "2017-10-19T15:00:00.0000000",
"TimeZone": "UTC"
},
"End": {
"DateTime": "2017-10-19T16:00:00.0000000",
"TimeZone": "UTC"
},
答
改变时区为UTC后,问题仍然存在。我发现它不起作用。在网络邮件中,虽然我在注册时填写了正确的时区,但时区设置为UTC-8 ... 感谢您的回答!