【问题标题】:Change an event from all-day to time-limited将活动从全天更改为限时活动
【发布时间】:2012-12-18 06:02:29
【问题描述】:

Google 日历上有一个全天活动,我把它拉了出来,把它改成 1 小时活动,我创建了补丁活动来推回。据我了解,全天活动的日期为“开始”,下一个日期为“结束”。限时事件有那些在 DateTime。

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

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

【问题讨论】:

    标签: google-calendar-api


    【解决方案1】:

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

    stanc 对问题 3110 的评论 #4...@google.com:将事件从全天修补到非全天失败 http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?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"
     }
    }
    

    结果事件最终会同时设置 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
     }
    }
    

    在代码中,当你想将字段 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
    

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-21
        • 2022-01-20
        • 1970-01-01
        • 1970-01-01
        • 2019-04-13
        相关资源
        最近更新 更多