Reputation: 7534
In my Google calendar, which is in the America/Toronto timezone, I have an event that is marked as an all day on the 13 April 2022, but it is coming back as starting on 2022-04-13 and ending on 2022-04-14. I have some other all day event behaving in the same way.
This is happening from my code, but also when I try with the API test form here:
https://developers.google.com/calendar/api/v3/reference/events/list
With parameters:
2022-04-10T18:36:39.000Z
2022-04-17T18:36:39.000Z
This returns me the following response (certain fields masked):
"kind": "calendar#events",
"etag": "\"p328ftm5rim7ve0g\"",
"summary": "My Test Calendar",
"updated": "2022-04-12T18:36:40.074Z",
"timeZone": "America/Toronto",
"accessRole": "owner",
"defaultReminders": [],
"nextSyncToken": "xxx-xxxx_cCEJD-2LuVj_cCGAUg8t3t0QE=",
"items": [
{
"kind": "calendar#event",
"etag": "\"3299577200148000\"",
"id": "xxxxga02nqb11ub6dm29dgg9t",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=xxxxxxnYTAybnFiMTF1YjZkbTI5ZGdnOXQgY19uZ2hqOXFzb25tYjRtNDRqN2doaTNxNzY5a0Bn&ctz=UTC",
"created": "2022-04-12T18:36:39.000Z",
"updated": "2022-04-12T18:36:40.074Z",
"summary": "Dummy Event",
"creator": {
"email": "xxxxxx",
"displayName": "xxxxxx"
},
"organizer": {
"email": "[email protected]",
"displayName": "My Test Calendar",
"self": true
},
"start": {
"date": "2022-04-13"
},
"end": {
"date": "2022-04-14"
},
"transparency": "transparent",
"iCalUID": "[email protected]",
"sequence": 0,
"reminders": {
"useDefault": false
},
"eventType": "default"
}
]
}
I tried providing both 'America/Toronto' and 'UTC' as timeZone
parameters in the request, but this does not change anything.
Can anyone suggest how to get an all day event to span only the day it is meant to be happening on?
BTW below you can see the event was only on a single day:
Upvotes: 0
Views: 825
Reputation: 5533
This is an expected behavior from the Calendar API. All day event last for 24 hours. Lasting from midnight of start date to midnight of the next day.
It is also written in the Event Resource that end
is exclusive.
An alternative solution to this is to -1 the end date of the response body or manually plot the time. But if you try to manually create an All day event by plotting the time, It can only last for 23.5 hrs.
Upvotes: 2