I have an app that uses the Calendar v3 API to create, query, and modify all-day events on Google Calendar. These events look something like this when I create them:
{
summary: 'My Event",
start: { date: '2014-07-26' },
end: { date: '2014-07-26' }
}
So if I want to query all of such events between July 20th and July 26th, I send a query like this:
GET www.googleapis.com/calendar/v3/{calendarID}/events?timeMin=2014-07-20T00%3A00%3A00.000Z&timeMax=2014-07-26T00%3A00%3A00.000Z
In a more readable format, the parameters are:
timeMin:2014-07-20T00:00:00.000Z
timeMax:2014-07-26T00:00:00.000Z
However, this excludes all of the events with the date 2014-07-26
, it gets only the events for the 20th to the 25th. In my parameters you can see that I have used setUTCHours(0)
in order to have no time zone information.
If I remove the calls to setUTCHours(0)
for the timeMin
and timeMax
parameters then I have the opposite problem, I get 7/21 through 7/26 and miss the events on 7/20. How can I reliably get all of the all-day events for the week in any time zone?
Just came across this myself. For filtering, the end time is exclusive while the start time is inclusive. See the events spec here. Presumably when you just specify a date and not a time, it treats it something like 00:00:00 UTC -- so not inclusive of that day. But that's just speculation on my part. Anyway, if you +1 to your end date it should work the way you expect it to.
I would ask for +1 day on both sides of the week and post-filter the events that are not interesting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With