0
votes

As show in the picture I want to get all events that are in the range (start and end) of my 'My Free Time' event. In this case there are three events that meet the requirements ('Learning for Exam', 'Homework', 'Coffee').
The 'Running' event start time is out of range of start-end time of 'My Free Time' event.
The 'Cycling' event end time is out of range of start-end time of 'My Free Time' event.

enter image description here

I am using Google Calendar API v3. I saw the 'timeMax' and 'timeMin' parameters in Google Calendar API Reference:
timeMax - Upper bound (exclusive) for an event's start time to filter by.
timeMin - Lower bound (inclusive) for an event's end time to filter by.

I make the following call:

$optParams = array(
    'maxResults' => 10,
    'orderBy' => 'startTime',
    'singleEvents' => TRUE,
    'timeMin' => '2018-11-27T07:30:00+01:00',
    'timeMax' => '2018-11-27T17:30:00+01:00',
);

Where timeMin is set to 'My Free Time' event startTime & timeMax is set to 'My Free Time' event endTime.

But in the result there are all the events ('Running', 'Learning for Exam', 'Homework', 'Coffee', 'Cycling'), instead of only 3 events 'Learning for Exam', 'Homework' and 'Coffee'.

The question is: how the timeMin & timeMax parameters should be set to obtain only the 'Learning for Exam' event ?

The following question is similar: Google Calendar Api get events on current week

but the answers don't fulfill my requirements. My requirements are:
- NOT get the events which start time is BEFORE start-time of the range and the end time is in the range i.e. BEFORE end-time of the range (ex. 'Running' event)
- NOT get the events which end time is AFTER end-time of the range and the start time is in the range i.e. AFTER start-time of the range (ex. 'Cycling' event)

1
Have you tried to add an optional query parameters 'q' => 'Learning for Exam', ? [link]developers.google.com/calendar/v3/reference/events/listJamie_D
@Jamie_D It's not the point, I also saw the 'q' parameter, instead 'Learning for Exam' there may be several events.Dragan Menoski

1 Answers

0
votes

timeMin--> 2018-11-27T10:30:00+01:00
timeMax--> 2018-11-27T15:30:00+01:00