Reputation: 534
I am using google calendar API to fetch the event lists. What I am doing over here is I am adding filter to get event of specific date, so for that I have used timeMin and timeMax keys. But this filter is not working at all. It is giving me results of other dates as well. Can someone please help me with what am I doing wrong?
Here is my request URL.
Thanks in advance!
Upvotes: 0
Views: 1345
Reputation: 26806
timeMin
and timeMax
parameters are confusing and do not correspond to the Date
options from...to
of the UI searchAs per documentation:
timeMax: Upper bound (exclusive) for an event's start time to filter by.
timeMin: Lower bound (exclusive) for an event's end time to filter by.
In other words, defining
timeMin=2021-07-15T00:00:00.000Z&timeMax=2021-07-17T00:00:00.000Z
will return you all events that started before 2021-07-17T00:00:00.000Z
and end after 2021-07-17T00:00:00.000Z
.
You need to modify the query and look for event on the date indirectly by e.g. looking for events that started before 2021-07-17T23:59:59.999Z
and ended after 2021-07-17T00:00:00.000Z
.
Thereby, make sure to set singleEvents
to true
to exlucde event series (recurring events).
Once you have a list of candidates, you might still need to query for the start
and end
properties of the event resource and filter out the spare results.
Upvotes: 2