Calendar
Event calendar access and manipulation
The user's calendars. Fetch, create, edit and delete events, including recurrence rules. Needs calendar access: status, isAuthorized and requestAccess() ask and answer for it; every read asks on its own the first time.
Properties
identifierStringCalendar identifier
titleStringCalendar title
isSubscribedBooleanWhether this is a subscribed calendar
allowsContentModificationsBooleanWhether this calendar allows modifications
colorColor ›Calendar color
statusString"authorized", "limited" (write only), "denied", "restricted" or "notDetermined".
isAuthorizedBooleanTrue when calendars can be read.
Methods
.supportsAvailability(availability)BooleanCheck if this calendar supports a given availability type.
- availability String required
.save()Save changes to this calendar.
.remove()Delete this calendar.
Calendar.requestAccess()StringShows the permission sheet. App only.
returns The status afterwards.
Calendar.presentPicker(allowMultiple?)[Calendar] ›Present the system calendar picker.
- allowMultiple Boolean
Calendar.all()[Calendar] ›Every event calendar.
Calendar.find(options)Calendar ›One calendar, or null when nothing matches.
- options Any required
One of these.
- title String
Match by name.
- identifier String
Match by identifier.
- default Boolean
The calendar new events go into.
- title String
Examples
Fetch today's events
const events = Event.fetch({
timeframe: "today"
});
for (const e of events) {
console.log(e.title, e.startDate.format("HH:mm"));
}Create recurring event
const event = new Event({
title: "Standup",
startDate: DateTime.from({hour: 9, minute: 30}),
endDate: DateTime.from({hour: 9, minute: 45})
});
event.setRecurrence({
frequency: "weekly", interval: 1
});
event.save();