1

I have a small script that pulls down my meetings via the Google Calendar Events.list API. I'd like it to ignore my "all day" meetings. It seems like it's not possible but I wanted to ask if anyone knows how.

SGC
  • 1,025
  • 1
  • 6
  • 6
pcg79
  • 1,283
  • 9
  • 20

1 Answers1

2

Take a look at the Event Resource Representation. (I've added comments.)

{
  "kind": "calendar#event",
  "etag": etag,
  "id": string,
  ...
  "start": {
    "date": date,               // All-day only
    "dateTime": datetime,       // Others only
    "timeZone": string
  },
  "end": {
    "date": date,               // All-day only
    "dateTime": datetime,       // Others only
    "timeZone": string
  },
  ...
}

The representation doesn't point out that all these properties are not present in every instance.

It turns out that all-day events start have a start.date property, while other events start have a start.datetime. Likewise for end. You can simply use that to filter out the uninteresting events.

You'll see these properties used in Google Apps Script: event.setTime error and time format.

Community
  • 1
  • 1
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • Ah, I didn't notice the "date" vs "dateTime" difference. Is there a way to filter that at the server level? I'd rather not have to get back all events and filter on the client end. – pcg79 Jul 17 '15 at 01:42
  • The query parameter `q` supports free-text queries, which is the only filter option other than start & end periods. I haven't found any way to get that to filter all-day events. If you were really disciplined, you could include identifying text in event titles or descriptions, then use `q` to seach those. But I think the most straight-forward approach is to pull the list for all, then remove undesirables from the result list. – Mogsdad Jul 17 '15 at 02:36
  • Yeah, I couldn't figure out how to use `q` to do it either. Oh well. I'll likely go with your suggestion. Thanks! – pcg79 Jul 20 '15 at 18:53
  • @Mogsdad I have events in calendar as abc 1, abc 2 but if i want to search for a specific event when I pass q=abc it displays all abc events but If i pass q=abc 1 it gives empty. Any suggestions please? I use calendar API mentioned https://developers.google.com/google-apps/calendar/v3/reference/events/list – Code Guy Oct 12 '17 at 05:11