Feature request: CalendarEvent.availability

Would it be possible to add an availability property to CalendarEvent?

(the equivalent of var availability: EKEventAvailability { get set } in Swift)

Possible values (as in EKEventAvailability):

  • notSupported
  • busy
  • free
  • tentative
  • unavailable

That’s a good idea. I’ll add it to the backlog.

1 Like

Thank you for adding this!

I’m using this to find “all day” events that are marked “busy” (but should be “free”):

function busy(event) {
  return event.isAllDay && event.availability == "busy" && !event.calendar.isSubscribed
}

let start = new Date()
let end = new Date(2018, 11, 31)
let events = await CalendarEvent.between(start, end)
let busyEvents = events.filter(busy)

for (event of busyEvents) {
  console.log(event.startDate + ": " + event.title + " (" + event.calendar.title + ")")
}

However there’s (/I do) something wrong: event.calendar seems to be empty ({})?

(as a result the title is undefined and the subscription check is failing)

@rob Thanks for reporting the issue. I’ve found and fixed the issue. It should work in the next build. Sorry for the inconvenience.

2 Likes

Solved!

Different issue: calendars that I subscribed to in the FastMail web interface return false for isSubscribed.

Maybe a FastMail/iOS issue?

EDIT: Drafts correctly returns false for allowsContentModifications, so maybe you can do something about this?

@rob The isSubscribed and allowsContentModifications properties are two different things. allowsContentModifications isn’t currently exposed by Scriptable but I’ll squeeze it in for the 1.1.0 release.

2 Likes

Thank you for adding allowsContentModifications.

Using this property (instead of isSubscribed - and without the negation) my script now works exactly as I want it to!

It immediately reported a calendar entry that I added with the wrong availability yesterday… :smile:

1 Like