日历中的Outlook API时间差异

我在使用Calendar API的时候遇到了问题,特别是使用了Calendar API。

我用UTC格式发送date,当它们被添加到日历中时,我与发送date有所不同。

我在法国,原来的date是UTC + 2。 我在UTC转换,并使用此configuration请求:

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" }; 

如果TimeZone是“OriginStartTimeZone”或“UTC”,我也有同样的问题。

例如,我的本地date是2017-10-19T17:00:00.000它被转换为UTC 2017-10-19T15:00:00.000Z而在日历中,事件date是2017-10-19T08:00:00.000

我错过了这个API?

谢谢!

OriginStartTimeZone不是TimeZone的有效值。 如果将TimeZone设置为UTC ,则应该获得预期的结果。 我只是用这个有效载荷在这里testing它:

 { "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" } } 

在响应我的POST和随后的事件GET请求,我回来了:

 "Start": { "DateTime": "2017-10-19T15:00:00.0000000", "TimeZone": "UTC" }, "End": { "DateTime": "2017-10-19T16:00:00.0000000", "TimeZone": "UTC" }, 

如果你想让你的活动开始date在当地时间10点30分到2017-10-19,你的开始对象应该是这样的:

 Start:{DateTime: "2017-10-19T10:30:00+02:00", TimeZone: "UTC"} 

这是你的起始对象的样子吗? 如果是这样,那么事件时间应该在日历中正确显示。

将时区更改为UTC后,问题仍然存在。 我发现它不起作用。 在networking邮件中,虽然我在注册时填写了正确的时区,但是时区已设置为UTC-8 …感谢您的回答!