将活动从全天变为限时

Tax*_*Noi 5 google-calendar-api

谷歌日历上有一个全天活动,我拉了它,把它改成1小时的活动,我创建补丁活动推回.据我所知,全天活动作为日期"开始",并且作为下一个日期"结束".限时事件具有DateTime中的事件.

所以在我的补丁中,我尝试将这些值从Date更改为DateTime.但是,我总是收到错误"开始和结束时间无效或不匹配".

我在Google Calendar API网站上手动尝试了此操作:https://developers.google.com/google-apps/calendar/v3/reference/events/patch#try-it 并收到相同的错误.如果我采取有时间限制的事件并对其进行修改,则不会出现问题.我相信这是API本身的一个错误.任何人都可以体验它,解决方法是什么?提前致谢.

Tax*_*Noi 11

更新:这是我从谷歌开发团队收到的,希望对某人有用:

问题3110评论#4由stanc ... @ google.com:从全天到非全天的修补活动失败 http://code.google.com/a/google.com/p/apps-api-问题/问题/细节?ID = 3110

修补程序操作采用原始事件并更改/添加/删除请求指定的条目.如果您针对全天事件向PATCH操作发送以下请求:

{
 "start": {
  "dateTime": "2012-05-17T06:30:00+06:30",
  "timeZone": "UTC"
 },
 "end": {
  "dateTime": "2012-05-17T07:30:00+06:30",
  "timeZone": "UTC"
 }
}
Run Code Online (Sandbox Code Playgroud)

生成的事件最终会同时设置dateTime和date字段(这是不允许的).因此,PATCH请求需要清除日期字段:

{
 "start": {
  "dateTime": "2012-05-17T06:30:00+06:30",
  "timeZone": "UTC",
  "date": null
 },
 "end": {
  "dateTime": "2012-05-17T07:30:00+06:30",
  "timeZone": "UTC",
  "date": null
 }
}
Run Code Online (Sandbox Code Playgroud)

在代码中,当您要将Date字段设置为null时,您必须Data.NULL_DATE_TIME像这样:

EventDateTime edt = new EventDateTime();
edt.put("date",Data.NULL_DATE_TIME);// if you put NULL, it doesn't retain.
edt.put("dateTime", newTime); //newTime is the new value you want to set, type DateTime
Run Code Online (Sandbox Code Playgroud)