Drafts Scripting Reference

Calendar

Calendar objects are used to manipulate and create calendars in the built-in Calendars app and its associated accounts.

Properties

Instance Functions

Class Functions

Class Properties

Examples

var calendar = Calendar.findOrCreate("Activities");
var event = calendar.createEvent();
event.title = "Dinner Party";
event.notes = "Bring side dish.";
event.startDate = Date.parse("7pm next friday");
event.endDate = Date.parse("10pm next friday");
event.isAllDay = false;
if (!event.update()) {
  console.log(event.lastError);
}
// load a calendar
let cal = Calendar.find("Test");
// loop over events in the last 30 days and alert the name of each.
if (cal) {
	let events = cal.events((30).days().ago(), new Date());
	for (let event of events) {
		alert(event.title);
	}
}