我正在使用Microsoft Graph创建event
。除了始终以UTC格式创建事件外,一切正常。我正在遵循文档中的示例,但仍然没有运气。
这是帖子的正文:
{
"subject": "My event",
"start": {
"dateTime": "2017-11-03T04:14:31.883Z",
"timeZone": "Eastern Standard Time"
},
"end": {
"dateTime": "2017-11-10T05:14:31.883Z",
"timeZone": "Eastern Standard Time"
}
}
以下是回复:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('...')/events/$entity",
"@odata.etag": "W/\"1OZnj8JcDU6yRK1K4rYSNQABJ3X/lw==\"",
"id": "...",
"createdDateTime": "2017-11-03T04:15:13.7075368Z",
"lastModifiedDateTime": "2017-11-03T04:15:13.7231636Z",
"changeKey": "1OZnj8JcDU6yRK1K4rYSNQABJ3X/lw==",
"categories": [],
"originalStartTimeZone": "UTC",
"originalEndTimeZone": "UTC",
"iCalUId": "...",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "My event",
"bodyPreview": "",
"importance": "normal",
"sensitivity": "normal",
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "busy",
"type": "singleInstance",
"webLink": "...",
"onlineMeetingUrl": null,
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00Z"
},
"body": {
"contentType": "text",
"content": ""
},
"start": {
"dateTime": "2017-11-03T04:14:31.8830000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2017-11-10T05:14:31.8830000",
"timeZone": "UTC"
},
}
答案 0 :(得分:2)
由于start
和end
属性代表dateTimeTimeZone
type和DateTime
属性,因此期望以yyyy-mm-ddThh:mm[:ss[.fffffff]]
格式指定值(请参阅Edm.DateTime type说明更多细节)。
在您的示例Z
中,2017-11-10T05:14:31.883Z
需要从'Z' is the zone designator for the zero UTC offset开始省略timeZone
,这就是{
"subject": "My event",
"start": {
"dateTime": "2017-11-03T04:14:31.8830000",
"timeZone": "Eastern Standard Time"
},
"end": {
"dateTime": "2017-11-10T05:14:31.8830000",
"timeZone": "Eastern Standard Time"
}
}
属性被忽略的原因。
例如:
var files = new DirectoryInfo(path).GetFiles("File")
.OrderByDescending(f => f.LastWriteTime).First();
答案 1 :(得分:0)
此代码段有效。
invite.Start.TimeZone = eventInvite.TimeZone;
invite.Start.DateTime = eventInvite.StartDateTime.LocalDateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", System.Globalization.CultureInfo.InvariantCulture);
invite.End.TimeZone = eventInvite.TimeZone;
invite.End.DateTime = eventInvite.EndDateTime.LocalDateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", System.Globalization.CultureInfo.InvariantCulture);