Создать событие не подтверждает, что часовой пояс передан в
Я использую 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"
},
}
1 ответ
Решение
Поскольку start
а также end
свойства представляют dateTimeTimeZone
тип и DateTime
свойство ожидает, что значение будет указано в yyyy-mm-ddThh:mm[:ss[.fffffff]]
формат (см. описание типа Edm.DateTime для более подробной информации).
В вашем примере Z
должен быть опущен из 2017-11-10T05:14:31.883Z
поскольку "Z" - это обозначение зоны для нулевого смещения UTC, поэтому 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"
}
}
Этот фрагмент кода работает.
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);