简体   繁体   中英

Google Calendar event list is not working as expected

I am testing Google Calendar Api's event list function on the test bed site. The response is not listing event as per the timeMin and timeMax values. Here are two cases. In both cases I should get a response with an event scheduled between 9:30 to 9:45. But it doesn't appear on the first case (time range: 9:00 to 10:00) but it appears on the second case (time range: 9:00 to 15:00). This didn't work until extended the time range to 15:00. Why is the api acting weirdly?

Case 1:

timeMin: 2015-11-06T09:00:00Z

timeMax: 2015-11-06T10:00:00Z

My Request: GET https://www.googleapis.com/calendar/v3/calendars/MY_EMAIL%40gmail.com/events?timeMax=2015-11-06T10%3A00%3A00Z&timeMin=2015-11-06T09%3A00%3A00Z&fields=description%2Citems(attendees%2Cdescription%2Cend%2Cid%2Cstart%2Csummary)%2Csummary%2CtimeZone&key={YOUR_API_KEY}

Response:

{
   "summary": "some summary",
   "timeZone": "America/New_York",
   "items": [
   ]
}

Case 2:

timeMin: 2015-11-06T09:00:00Z

timeMax: 2015-11-06T15:00:00Z

My Request: GET https://www.googleapis.com/calendar/v3/calendars/MY_EMAIL%40gmail.com/events?timeMax=2015-11-06T15%3A00%3A00Z&timeMin=2015-11-06T09%3A00%3A00Z&fields=description%2Citems(attendees%2Cdescription%2Cend%2Cid%2Cstart%2Csummary)%2Csummary%2CtimeZone&key={YOUR_API_KEY}

Response:

{
 "summary": "Some summary",
 "timeZone": "America/New_York",
 "items": [
  {
   "id": "u7tt4icrbfe76tso8qt11oa5gg",
   "summary": "Event summary",
   "description": "Event description",
   "start": {
    "dateTime": "2015-11-06T09:30:00-05:00",
    "timeZone": "America/Indiana/Indianapolis"
   },
   "end": {
    "dateTime": "2015-11-06T09:45:00-05:00",
    "timeZone": "America/Indiana/Indianapolis"
   }
  }
 ]
}

These times are UTC (from your interval in your first request):

timeMin: 2015-11-06T09:00:00Z
timeMax: 2015-11-06T10:00:00Z

These times are offset: -05:00 (from the results in your second request):

"dateTime": "2015-11-06T09:30:00-05:00"
"dateTime": "2015-11-06T09:45:00-05:00"

Your first time interval doesn't include those times due to the offset.

Update

@jaykumarark and I chatted about this and it appears to me that he's not missing anything - in order to use this API you have to provide an RFC3339 compliant date stamp including time zone (Z or offset from UTC) so you can't get the server to do the timezone offset calculation for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM