1

I am using the Google calendar API with Python, in order to compile events on a given day, to see how much time I spend on certain events per day/week etc.

I was originally just subtracting the End time from the Start time to achieve a Duration, and then adding all event Duration on a given day.

The thing is, sometimes I overlap events, for example Lunch and Reading might overlap and then cause the program to believe I've magically spent an extra 30 minutes in a day.

The google API gives (as can be seen here) the following values amongst others:

  "start": {
    "date": date,
    "dateTime": datetime,
    "timeZone": string
  },
  "end": {
    "date": date,
    "dateTime": datetime,
    "timeZone": string

So if I have a long list of Event objects, that all have a Start and End time, what would be a good way of checking that there are Event overlaps?

k4kuz0
  • 1,045
  • 1
  • 10
  • 24
  • 2
    Have you had a look at this http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap?rq=1 – domino Jun 12 '15 at 08:33
  • Great link, thanks! Didn't come up through my searches. I'll take a long look now. – k4kuz0 Jun 12 '15 at 08:47
  • In that case I guess I could also pose this question: How would you check a list of events with Start and End datetimes. Would you have to check every event against each other, or is there a better way of doing it? – k4kuz0 Jun 12 '15 at 08:48
  • 1
    Not sure what you mean by "check a list of events with Start and End datetimes". Now that the main question you asked is no longer relevant it would be better to update it to mention what exactly it is you want to do so that you get an answer – domino Jun 12 '15 at 10:31
  • @k4kuz0: somewhat related: [Python - Removing overlapping lists](http://stackoverflow.com/a/16314541/4279) – jfs Jun 12 '15 at 18:27

0 Answers0