Google 日历 API 错误 - 结束日期为 - 1

Google Calendar API Bug - End date is - 1

Google 日历 API 将 end.date 视为 end.date - 1

我的POST有效载荷

{
    'summary': 'THREE DAY EVENT',
    'status': 'confirmed',
    'start': {
        'date': '2020-01-27',
        'timeZone': 'America/Los_Angeles'
    },
    'end': {
        'date': '2020-01-29',
        'timeZone': 'America/Los_Angeles'
    }
}

这会在我的日历上产生以下事件

注意这3天全天的结束日期是负1

当我对事件 ID 执行 GET 时,我返回了一个正确的对象。

{
    'kind': 'calendar#event',
    'etag': '"REDACTED"',
    'id': 'REDACTED',
    'status': 'confirmed',
    'htmlLink': 'REDACTED',
    'created': '2020-01-22T20:15:23.000Z',
    'updated': '2020-01-22T20:15:23.896Z',
    'summary': 'THREE DAY EVENT',
    'creator': {'email': 'REDACTED'},
    'organizer': {'email': 'REDACTED',
    'displayName': 'REDACTED',
    'self': True},
    'start': {'date': '2020-01-27'},
    'end': {'date': '2020-01-29'},
    'iCalUID': 'REDACTED',
    'sequence': 0,
    'reminders': {'useDefault': True}
}

我看过这个post -- Google Calendar API: Event endTime is decremented by 1 day

根据 Google 日历 API 文档:https://developers.google.com/calendar/v3/reference/events/insert#request-body

end.date -- The date, in the format "yyyy-mm-dd", if this is an all-day event.

对于 all-day 事件,不需要时间字符串,结果事件应该在我提供的范围内。结果 API 响应是正确的,但 Google 日历中的事件不是...

在APIofficial documentation中可以看到,参数end指的是事件的独占结束时间,即对比start,指的是包含的开始时间。

即结束日期不包括在事件中,而是前一天。

参考:

希望对您有所帮助。