Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Google Calendar Lower Bounds for Start Time  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there it's my first time using an API. I'm having a little trouble with the google calendar api. What i have is after a event gets printed out it gets the next event



The above is code to get the next event. But my problem is this:



The problem is when i run it, it says the next event is "example event". For me the next event should be "2nd event" because the start time of "example event" has already passed.

In the api there is a timeMax:


Timemax is the upper bounds of the start time. But what I really need is the lower bounds of the start time and the api doesn't have that.

Link to full list of parameters in the api: https://developers.google.com/google-apps/calendar/v3/reference/events/list

If my start time is [lower bounds, upper bounds] I want [the time now, upperbounds]

I guess a possible solution would be to get not just the "next event" but get like the "next 10 events". Then have a comparater to check if the event's start time (which i can get after i retrieve the events) is less than the current time.

If not get the "next event"

I'm just thinking worst case if all 10 events start before the start time and the 11th event starts after then the 11th event wouldn't get retrieved.

I'd have to use the list method with a query of 20 and repeat to get the "next 20 events" and perhaps have a counter on the last position (10).

I might also need to have an event in like 2050 or something so there will also be an event in the future.

Is that the best solution for this?
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just going to try my solution.
I'll post how it goes here later.
I can always just convert to a diff solution later as well.
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My solution works.
Might not be the best solution, but gets the job done.
Set the range to 20 and filter for what i want.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!