Sub topic 6
Creating calendars and events
This chapter assumes you have already added at least one account in System Settings and know that an account decides where a calendar's data lives. Here you will create calendars, add events to them, and check the result with a short script.
How calendars and events relate
A calendar is a named container, and an event is an item stored inside one calendar. Each calendar belongs to one account, such as iCloud or Exchange. The account determines where the events are stored and which devices see them. An event created in a calendar on your Mac account (labeled "On My Mac") never leaves that Mac.
Creating a calendar
- Open Calendar.
- Choose File > New Calendar, then pick the account the calendar should belong to.
- Type a name and press Return.
- Control-click the calendar in the sidebar and choose Get Info to set a color. You can also turn on alerts for new events here.
Pick the account first. A calendar cannot be moved between accounts by dragging it. You would have to create a new calendar in the other account and move the events.
Creating an event
You can create an event in several ways:
- Double-click a time slot in Day or Week view.
- Click the plus button in the toolbar and type a sentence such as
Lunch with Sam Friday at noon. Calendar reads the date and time from the text. - Choose File > New Event.
Double-click the event to open its details. The main fields are:
| Field | What it does |
|---|---|
| Title and location | Names the event. A location can offer travel time suggestions. |
| All-day | Removes the start and end times. |
| Repeat | Sets a recurrence such as daily, weekly, or a custom pattern. |
| Alert | Notifies you before the event, for example 15 minutes ahead. |
| Calendar | Picks which calendar stores the event. |
| Time zone | Fixes the event to a zone, or lets it follow your current zone. |
Change the Calendar field of an existing event to move it to another calendar. This works only for calendars in the same account.
Editing repeating events
When you change a repeating event, Calendar asks whether the change applies to this event only or to all future events. Choose carefully. Changing all events rewrites the series, and exceptions you made earlier can be lost.
Checking your calendars with AppleScript
Reading the calendar list confirms that scripting access works. The first run may show a permission prompt, which you must allow.
tell application "Calendar"
get name of every calendar
end tellUse the exact names it returns in later scripts. A name that differs by one character, such as a trailing space, will not match.
Common errors
- An event appears on your Mac but not on your iPhone. The calendar is probably in "On My Mac" rather than iCloud. Move the event to an iCloud calendar.
- The new calendar option is grayed out. The selected account may not allow calendars to be created, as with some read-only subscribed calendars.
- Event times look wrong after travel. Check whether the event is set to a fixed time zone.
Exercise
You created an event in a calendar listed under "On My Mac", and it doesn't show up on your iPhone. Why, and how do you fix it?
Show answer
Calendars under "On My Mac" are stored only on that Mac and are not synced. Open the event, change its Calendar field to a calendar in your iCloud account (or another syncing account), and it will sync to your other devices.
Exercise
What does the AppleScript get name of every calendar return, and why is it useful before writing other scripts?
Show answer
It returns a list of the names of all calendars Calendar knows about. You then use those exact names in later scripts so they target the right calendar.